Its a little bit genetic and a little bit learned. Your immune system has the ability to learn and adapt, otherwise you would be sick all the time. From the ever improving Wikipedia:
Allergies are an abnormal immune reaction. The human immune system is
designed to protect the body from potential harm and in people who have
allergies the immune system will react to allergens (substances that
trigger an immune response).
Though I’m no expert in immunology or allergens, I bet they probably tell you what your are innately allergic to, not what you will be allergic to. @Seaine, its possible both your parents have the recessive gene for those allergens, but its masked by the non-allergenic dominate gene.
It may or may not be related, but a recent study shows that phobias may be learned from our ancestors, and if you can pass on phobias, it may be possible that you can pass on developed/lost allergies. Seems for everything we learn about the human condition there’s more we find that we don’t know.