As far as me not being a nerd - you didn't know me 20+ years ago. Before about 2003 I was as aspie retard as they come. A large part of me still screams that people are always the problem and that things won't come at you by themselves and hurt you for spite but people will do so.
The other big current thread on this site at
the thread about men's support forums where we segued into being connected through niche identities is relevant to this thread. Hobbies, pastimes, subject interests, and geek fixations can all be used to create tribal identities. Along with race, national origin, language, and other aspects.
Past military service. Generically it's a pretty good peer group when it's service members from a specific country. Even more social cohesion among members of particular branches of service. And the ultimate social affiliation happens between guys (or women) who were in the same units, squadrons, camps, outposts, etc.
For instance, a video on a Youtube channel I subscribed to about affordable performance cars - the guy has one video where he discusses "normies" or non-car people, people who don't care about performance. He uses the word "normies" and humorously uses a Pepe meme of holding a shotgun at his own head. (He was doing this to segue into discussing budget cars at a certain price point.) In other words, "normies who aren't into cars, kill yourselves." (I laughed my ass off with his performance.)
The point here being that car enthusiasts consider their interest level a sign of distinction and brotherhood.
Many church cultures are quite similar.
Programming can be both like a religion calling as well as a shared interest tribe. Outsiders are considered stupid, unknowledgeable, uncultured, not as worthy, and less-than. The tribalism in programming can extend to programming niches... lightweight vs heavyweight "bare metal" developers.
Or, ideological groupings. I think the Trump presidency and the alt-right galvanized a lot of middle-income and middle class whites into a feeling of belonging and cared for that they get nowhere else. (DON'T turn this into a political thread. Just using as an example.)
Lastly, perception of shared hardship adds a lot of social cohesion. Military is (in my opinion) the absolute tops for this. Blacks and some other minorities may experience fellowship through feeling of shared hardship. Programmers are the grown up equivalent of the nerd's table in the high school cafeteria.
The shared hardship may be a huge barrier to acceptance of an outsider.
Maybe people naturally seek identity thereby inducting themselves into a distinct peer group, for mutual admiration, protection and fellowship.