The primatologist Richard Wrangam once advanced the theory that tribe vs. tribe conspecific homicides - what he called coalitionary killing - are an evolved trait that was selected for in primates by some kind of pro-homicide selection pressures in the ancestral environment (where homicide reliably grants an advantage to the expected relative gene frequency of the perpetrator's genes). I haven't kept up with biology…
Worth adding some nuance to the Wrangham framing here — he's not wrong exactly, but de Waal spent decades documenting the flip side: chimps reconcile, console each other, maintain coalitions in ways that don't fit the "demonic males" narrative cleanly. Both are true, and which one you see probably depends a lot on which population you're studying and under what conditions. Ngogo (which I think this is) is in a fragme…
I remember reading, not sure if it's from de Waal, about chimp "raiding parties", where groups of young males will get excited and loudly vocalise as they gather together and head towards a neighboring territory, but when they get close they all go very silent, and will attack individuals from a neighboring troop if they sufficiently outnumber them. They tend to target the face and genitals when attacking other chimps, a different behaviour to when they're hunting monkeys, for example. I think Wrangham mentions that some chimps will hold the targeted individuals' limbs while others attack.
Aside from the brutality, these behaviours seem too cogently goal-directed and sophisticated to just be responses to environmental pressures. There's some deeper reasons involved, imo, even if the severity of the violence is exacerbated by resource and territorial pressures.