This may not be entirely so. Hate and fear are so ubiquitous in all societies that it would seem unlikely to be just a learned behavior. Group Think is characterized by a feeling of comfort when with those within your group and discomfort when associating with those not in the group. This can lead to associating negative characteristics to anyone who is not part of your group and hence create attitudes such as racism.
Groups seem to form almost spontaneously in any social setting.
Their pervasiveness is seen from the fact that they occur in all societies, from the advanced to primitive. They each set up rules for their members behavior to help distinguish themselves from those who are not part of the group and frequently include some type of initiation procedure to bring in new members. Of course, groups that consist of members with a particular heritable lineage are closed to others. Our human need to form groups of various kinds crosses all cultural, ethnic, religious, and national boundaries. When a group becomes large and successful, the usual result is to splinter and form more groups as religions, nations or businesses seem to do with great regularity.