I think there's two, in evolutionary terms, two things going on here. It clearly is adaptive to think in group terms because your survival depends on the group. But there's another adaptive response, which is self-interest. And so when things are bad, you're way better off investing in the group and forgetting about yourself.
Journalist and author Sebastian Junger talks about his book Tribe with EconTalk host Russ Roberts. Junger explores the human need to be needed and the challenges facing many individuals in modern society who struggle to connect with others. His studies of communal connection include soldiers in a small combat unit and American Indian society in the nineteenth century.