What you're saying is a generalization and stereotypical, but when it occurs it's due to their personalities usually. They tend to be quiet, reserved, etc and that leads to a couple of things:
* Being misunderstood by people. Some people will think they're stuck up because they don't socialize, but that's usually not the case. They're more than likely shy due to poor social skills, especially during an awkward time in life. In a smaller percentage of cases, though, you'll have the geeks / nerds with a superiority complex and they really are stuck up and arrogant. Even if they are intellectually superior, the attitude is usually due to insecurities or shortcomings in other areas (like being able to relate to people).
* Being picked on by 'stronger' personality types. If somebody who is popular makes fun of or disparages somebody else, especially when they're seen as different, the people in the aggressor's circle will tend to do the same. As will people who are friends with people in the aggressor's circle or people who want to be in the aggressor's circle. The aggressors, stereotypically, are 'jocks' and athletes and/ or those coming from a privileged background.
Of course, you'll have those labeled as geeks or nerds simply because they look the part or because they're dirty or gross looking, and in these cases, it has nothing to do with how well the do in school.
I was and forever will be a geek.