Yeah, they spoil , same as any food stuff.
My fish are tiny, even the smallest food pouch lasts forever. I renew my food every few months.
Some people buy in bulk, remove what they need for a month and seal the main container air tight.
If possible, have 2-3 different foods on the go, with varying nutrients/ minerals. This will help keep fish healthy.
I have at least 9 staple foods from multiple manufacturers Plus they get algae wafers, cucumber, melon, courgette , lettuce and the occasional bit if chicken and live microworm. Fish go nuts for microworm.