It sounds like your little boy has an allergy issue.
Food allergies are common, especially in the first 3 years of life.
There is up to a 50% crossover in intolerance between cow milk and soy protein formulas, so, some of those allergic to cow’s milk are also allergic to soy.
Probably, he is allergic to nuts, also.
A food allergy might cause loose stools, excess gas, diarrhea, nausea, or vomiting.
Children that aren't breastfeeding, but, formula fed, have increased chances to develop food allergy.