how does waste prevent a shortage from becoming a famine ?
Making the expected production a higher number than the expected need will give the headroom necessary to deal with a shortage without people starving.
If you're aiming to produce food for a population of 100,000, but have the capacity to make food for 200,000, then you can afford to waste half of your food without starvation. You can also accommodate a 50% drop in production without starvation.
So that buffer is expected waste, but it's also starvation resistance.
If you're accommodating another group of people you should produce enough to always feed them, too, not just sometimes in surplus years. The whole point is that you've gotta plan for a surplus, otherwise you risk starvation in bad years (and it doesn't make it any better, morally, if the people who bear the risk of starving are "another group or people").