Why people starve under capitalism: because of greed.
Why people starve under socialism: no incentive to do better.
People think there are laws preventing companies, but there aren't.
Nope, it's never happened.
"There is no available public record of anyone in the United States being sued...because of harms related to donated food."
“As long as no one has acted in a totally reckless or deliberately destructive manner, lawyers are not interested in sticking it to people who make sure the needy do not starve, Civita wrote in “Food Recovery, Donation, and the Law in Food Waste Across the Supply Chain: A Global Perspective on a US Problem.” “What is more, the very people who depend on donated food – the potential plaintiffs – hesitate to bite the hands that feed them.”"
Except there are laws that do hinder or prevent it. It's different in every state/county/city. Some allow donating expired food, if it is still good, while others ban it outright. Some have regulations on what can be donated and/or how it's handled. It all adds up to extra time/manpower/cost that just becomes too much of a hassle to some companies.
It doesn't really matter if no one has sued, yet. In this sue happy time, it only takes the threat of one for people to not even bother. And you get a judge who often sides with the "underdog" even if they are in the wrong. Of course, the key word there was public record. Who knows what lies within any that were sealed.
As for your first comment, yes, greed can lead to others starving. However, that is a human condition that has nothing to do with capatilism. If anything, it is capatilism that has raised so many out of poverty and starvation. And with so many doing so well, it is easier to find those who have the means to donate to those less fortunate.
In socialist societies, it is not the lack of incentive that leads to starvation, but a central government or dictator who oppressed their/his/her people to remain in power. Often their greed and poor policies are what leads to a lack of resources and/or food.