Unless the seal on the baby food jar had been broken, it is doubtful that the baby food was the cause of the problem. Expiration dates on cans and bottles are there mainly for quality purposes, not for safety purposes. Nutrition and flavor will deteriorate over time.
Baby food companies perform what they call shelf-life testing to find out how long a product can stay on the shelf and still maintain the best nutrition and flavor. Then they date the product conservatively. For your baby's best nutritional health, always be sure to use a baby food well before its expiration date.
You need to be certain that whenever you open a baby food jar that first you check the lid to make sure the safety button is down, and then hold the jar near your ear when you twist it open to be able to hear the pop and whoosh of air that indicates you have broken the vacuum seal. And finally, just do a double check of the food inside by looking and smelling to satisfy yourself that everything is okay.