Most early humans cooperated and shared because they spent their entire lives surrounded by the same a few hundred people.
It's the same today. We still cooperate and share with about a few hundred closest people, and for everyone else, we have capitalism. Whenever the two meet, we shock-horror a bit about the callousness of others, and then we go back to treating everyone outside our Dunbar number as an object to extract resources from.
I don't want to suggest that it's biologically inevitable, but that we aren't going to overcome it until we start recognizing the blind spots in our cognition and empathy.