This tendency arises because you often associate identity and self-esteem with group membership, thereafter creating in-group favoritism and, conversely, out-group bias. Social psychologists Henri Tajfel and John Turner established research in this area, published as "The Social Identity Theory of Intergroup Behavior" in Political Psychology in 2013, that has since been corroborated many times. It showed that with the tiniest of associations, even completely arbitrary ones (like defining groups based on coin tosses), people will favor their "group."
Chapter:
Becoming One with Nature
Section:
Order Out Of Chaos