In the process of reading this book by Ezra Klein. One researcher he cites is Henri Tajfel, who found that once we humans categorize things, assign labels to them whether it's groups of people, symbols, or whatever, we start acting on it. With respect to people this led to:
"They proposed that people have an inbuilt tendency to categorize themselves into one or more "ingroups", building a part of their identity on the basis of membership of that group and enforcing boundaries with other groups.
Social identity theory suggests that people identify with groups in such a way as to maximize positive distinctiveness. Groups offer both identity (they tell us who we are) and self-esteem (they make us feel good about ourselves). The theory of social identity has had a very substantial impact on many areas of social psychology, including group dynamics, intergroup relations, prejudice and stereotyping, and organizational psychology."
Klein notes the dynamics of sports fans, where the objective differences among teams are trivial, but the fanaticism can be large.