A lot of stereotypes, if not most stereotypes, are built upon some sort of truth that applied to some people. The magic of extrapolation did the rest, and now some groups immediately evoke some ideas in one's mind.

As a result, most people will think that "X group = Y characteristic" and that X can't function without Y. They have accepted this as some kind of social axiom, and will be left dumbfounded when they meet someone who doesn't match that stereotype.

Nowadays, this applies a lot to political opinions, in a world were social injustices aren't kept behind closed doors. Many people will assume that because someone belongs to a marginalized group, it has to mean they agree with certain opinion and beliefs, because it seems to be "what's good for them/their rights".