I believe humans are pack animals.
So like wolves, we stick together in our known group and snarl at other packs
Maybe not quite, but we are descended from people who had to look after their compound of huts, their village, and so on, for mutual benefit.
FIght and flight are base instincts. We worry about outsiders, "other" people. Are you racist? No? Well how would you like to be the only white, or black, household in the street?
It's innate - inbred.
You know you can get a Pavlovian response from dogs - you ring a bell and feed them. Before long, you ring the bell and they salivate.
The surprise is, that that response is passed on to puppies, even though it was never "taught" during the puppy's gestation or life. It's in the Epi Dna
We do know to some extent how it works, It's not IN the dna but AROUND the DNA. It's Epigenetic. Look up
Transgenerational epigenetic inheritance. You should find yourself in histones and nucleosomes.
Interesting stuff. It's about how particular parts of the DNA are hidden or exposed, in simple terms.
They go to affect behaviour. Life-threatening things have the stongests impact. Like Wars..
The way the bit of DNA. I'll imprecisely call a genotype, is EXPRESSED is subject to environmental conditions. So you can have identical twins with different automatic behaviours. Its alterability is referred to as phenotypic plasticity.
Also, if you move a herd of antelope from South Africa (yellow sand) to Namibia (Red Sand),
within their lifetime, their pelt reddens - for camo. And the colouring is strongly shown in the offspring.
I degress - but yes we're designed and programmed to look after our family/clan/tribe/village/country, because we survive better that way.
And has been like that, a long time.