1. Why is it that some foods cause an allergic reaction and others don't?
Hypersensitivity reactions are what commonly occur to foods which there are four types. The peanut allergy is caused by a type I reaction mediated by IgE. Peanuts in general are highly allergenic because of their chemical composition, some people’s immune systems will react and others won’t because of the variance in our immune systems. So using the peanut example what commonly happens is the person is exposed to peanuts 1 or 2 times before the reaction becomes anaphylactic. The peanut is ingested for the first few times and the body becomes sensitized to the antigen (peanut) and starts to produce an antibody known as IgE against it. IgE binds to receptors on mast cells which cause them to degranulate releasing histamine causing a variety of reactions ie. Shortness breath. Lots of IgE is formed against the peanuts after 1-2 times of exposure and the next time you consume it will cause a large anaphylactic reaction since it will bind to many mast cells.
With other foods like dairy the body reacts to the protein called casein in it causing IgG to form which is a type 3 immune reaction. IgG is a delayed response so symptoms are more subtle like gas, bloating, skin reactions, mucus formation, etc. (This is not the same as lactose intolerance which is lack of the enzyme lactase causing the inability to break down dairy.)
Some foods are just more commonly recognized by the body as foreign and really it just depends on the person and their immune system.