The hypothesis (that still needs to be confirmed) is that a gut infection potentially causes good bacteria to act strangely (e.g. overgrowing), your gut to be leaky (i.e. let bacteria invade other parts of your body like your bloodstream), and then your immune system is forced to respond to these bacteria and start treating them as bad. At that point, your body has trained itself to treat these good bacteria as bad bacteria, and then your immune system is just totally thrown off.
I blogged about this before, but I had several serious bouts of food poisoning when I was younger and I've often wondered if those events threw my system off. Interesting research though.
Here's an excerpt:
Most likely, Hand said, the immune system is indirectly responsible for spreading the good gut bacteria around. A strong immune response can damage body cells, including the gut cells that usually keep beneficial bacteria on the inside of the intestines.
Once the parasite infection is over, the researchers found, the immune system locks in a memory of the invaders it fought in memory T cells. These cells are able to mount a fast immune response if they encounter the same pathogens for a second or third time.
Unfortunately, the T cells remember the beneficial gut bacteria as well as the parasite, the researchers report online today (Aug. 23) in the journal Science. This memory seems to last as long as the mouse lives, Hand said.