@alisha-- Everyone gets flatulence from those foods, it's normal. Fiber causes flatulence because fiber is broken down in the intestines.
If you feel that the flatulence you get is abnormal and if you have other symptoms like severe abdominal bloating and pain, you might want to get tested for allergies.
Eating bad food can also cause flatulence. You should eat freshly cooked foods and avoid leftover meals. I once got food poisoning from leftover food and one of the problems it caused was flatulence.