I can’t answer that fully, but I’ll do my best.
Your mouth and mucus membranes may be one entry-point for some bacteria.
Also:
Bacteria may have left excretions on the food (e.g. more or less toxic substances), that may be responsible for the stomach-reaction (or even death .. depending on the bacteria).
I don’t know, if I’m missing something (I’m not a doctor/professional), but that’s my 5 cents.
Latest Answers