But you should assume that someone, in their own mind, thinks they're doing the "right thing".
If you assume people are evil and are motivated by wanting to pursue evil ends, then you're going to have a bad model for predicting them.
Everybody at that store wants to get the milk because in that situation, that's what feels like the right thing to do, all things considered. They're not getting up at 5am to ensure you DON'T have milk. If there weren't milk shortages, they wouldn't be buying it up just to spite you.
Everyone is picking the best option on the internal menu that they see in their mind.
It's simple game theory. The prisoners dilemma has multiple equilibria, but you don't find the optimal one unless you take the less rational choice once in a while.
I also agree it's simple game theory, but ignoring the HN audience for a moment you're probably assuming that the non-zero sum situation will still continue to hold at a society-wide scale for large parts of the world (at least for the "former" Western world).
The present covid crisis has proven that to be false, what with countries/states members of the same political union (the EU, different US States) fighting for limited medical resources in the early stages of the pandemic. We'll probably end up in similar scenarios if and when the climate crisis will worsen, reducing the availability for resources for many of us.
But I for example grew up in a society (Eastern Europe before 1989) where my dad had to wake up early at 4.45 or 5AM in order to go the State-owned grocery store, hoping to catch one bottle of milk for child-me out of a limited supply of 100 or 200 bottles (or something like that). That was a hell of a "zero-sum game" (you wake up early and you're lucky, you get a bottle of milk for your kid out of a limited supply, you don't, your kid is out of milk). As such, it's very difficult for me (and close to impossible) not to view the other people as potential adversaries.
In other words, viewpoints like the one you suggest ("everyone else is not an adversary") most probably come from a position of privilege, i.e. of having grown up in a society which afforded itself the luxury of not having everything as a zero-sum game.