Allergies

Sunshine
I'm wondering how children come out with food allergies. I was always told to eat common food allergies while pregnant and your kid won't have them. But for the kids that do still end up having allergies to foods why didn't they get sick while mom was pregnant?