One part of it could be from eliminating triggering food/s.
You will know once you start including foods one by one first the safest foods, later the less safe one.
Another part could be from improved immunity. People who are fasting have improved immunity against bacteria, virus and fungi, and fasting is an excellent way of curing stubborn infections.
In old times, before the invention of Antibiotics , antifungals and antivirals, fasting was used as the most effective treatment for any kind of infection, including the most deadly ones.