Meet Mia, she is an American citizen, holds a steady job, studying in XYZ university, enjoys cooking and more within the realm of her belief.

What about you? Who are you ?
Well, you will come across tons of ways to identify yourself, family, friends, interest, religious affiliations, etc. The groups you belong to are your in-groups or “Us” ; while those who don’t belong are known as out-groups. For example, someone from a different country, university, religious background also called “Them.”
History
This very science of Us vs them is Social Identity Theory. In 1970s Henri Tajfel and John Turner (British) proposed a theory, which now is considered one of the greatest contribution to psychology. As a Polish Jew, Henry was highly influenced by the second World War and Holocaust. During his years as a prisoner of War, Henry wanted to know what motivates humans to make such extreme decision. Hence, he pursued a career in prejudice and nationalism.
Tajfel and Turner theory proposes, we humans have an innate desire to boost our self-esteem. That is why we stereotype (based on a normal cognitive process) the out-groups and in-groups; that not only puts people in different groups and categories. But by doing so, we build a world divided between Us Vs Them.

How does the Cognitive Process work?
Tajfel and Turner (1979) proposed three mental stages of evaluating others in forms of Us and Them.
Social Categorization
We categorize things in order to understand and identify them easier, same goes with people. Either by profession, religion, gender, nationality, manners and so forth. How you perceive and categorize the world is shaped by your birth place and how you were raised.
Social Identification
Once you have divided the world in different categories, its time to identify yourself. Where do you fit? You could be a student, teacher, Catholic, Muslim, Man, Woman, non-binary and so on. This social identification gives us a sense of belonging in the real world.
Maslow Hierarchy of Needs is one of the best way to understand what motivates and drive people to make any decision. This motivational theory explains once we cover our basic needs, food, shelter, etc. Then we start looking for love and belonging and as a result build emotional significance to the groups we belong. Which also helps shape the way we act, speak and other maintenance we go through to fit in this group. From the car we drive to place we end up residing.

Social Comparison
This stage is better explained as Us vs Them mentality. We make direct but bias comparison between the in-group and out-group. Naturally we tend to look Us, the in-group through more favorable lens while categorizing Them, the out-group as inferior.

Tajfel and Turner along with his colleagues conducted a series of mini studies also called Minimal-group studies in the early 70s. The groups were as arbitrary and meaningless as possible.
Let me give you an example, participants were given a picture of dots and had to guess the total number of dots. Well if your guess was above 30 you are assigned to Group A and if you guess less than, 30 Group B. By doing this, the psychologists were able to create arbitrary groups; however when the participants were asked to assign points. The in-group members received higher points than the out group.
Which suggests just the simple act of categorizing humans can lead them to think in terms of Us and them rather than individuals. By doing this, people automatically subject the two groups to bias; ingroup favoritism and outgroup derogation. Meaning, in the sights of identical scenarios, ingroup members are viewed in positive manner while the outgroup members in negative manner.
People work with simple logic, I am good person; hence the group I belong to is automatically good or at least the one I don’t belong is bad. This sense of positive social identity in result rewards our self-esteem. In its extreme form these biases or prejudice can easily go from racism to genocide. A familiar example, Rwanda between the Hutus and Tutsis, Germany with the Jews , and more.
Wrapping Up
It is crucial to understand that group membership is not artificial or foreign that is strapped onto you, it is a true part of you. There is only way to understand it better, learning as you go.