We categorize people, and then use those categories to draw inferences about them. Our minds are busy, so sometimes this is a passive and mindless sort of thing. But other times it is active and thoughtful. In addition to category-based knowledge, we often have more immediately observed information about people's behaviors, traits, and appearance (which also have to be labeled and interpreted), and so we also have to integrate all this preexisting and incoming information. Since the time of the ancient Greeks, most philosophers and psychologists have agreed that we often process information in a "top-down" fashion—that what we "know" dictates what we "see" every bit as much as the reverse. What we call "experience" is always a function of both prior theories held in memory and present input from our sensory apparatus. There are no naked experiences. Those that involve other people are especially likely to be cognitively adorned, just because behavior must be interpreted in terms of contextual factors and inferred intentions.
In modern cognitive psychology, the notion of schemas has been used to represent the prior-knowledge part of the equation. "Schemas" may loosely be defined as theories we have about categories, and they function as frameworks for understanding what we see and hear. Some of these theories may be quite impoverished—I do not, for example, have any sort of elaborate theory about earthworms—but for important categories (say, occupations or gender), I have extensive knowledge that is bound together by quite complex theoretical ideas. A student who observes a professor giving a lecture will have schemas for the professor role, for the lecturing process, and for various other categories (male, Hispanic, young) that this particular professor fits. Thus stereotypes can be thought of, among other things, as schemas.
It is not obvious that we need an elaborate psychological construct, such as that of the schema, to help us understand how people construe their worlds. For example,