When you ingest something that you can't digest directly, there is a good chance that some bacteria in your guy can. And when they do, they multiply, this process is often faster than most people realize.
The problem rarely are the bacteria themselves, but the byproducts of their own metabolism, that can be benign is trace quantities and harmful in larger quantities.
The immune system also constantly monitors and reacts to those byproducts and bacteria population.
What we usually call Lactose intolerance or Gluten sensitivity is in practice an indirect effect of some species of bacteria digesting those, and then the reaction of your immune system.
Overall, the gut microbiome is a fascinating and complex subject, unfortunately often oversimplified or misunderstood.
As an example, we've often been told to eat more fibers to increase "flow", the flow increase is because the fibers are digested by bacteria and the mild toxicity of the process forces the digestive system to flush everything.
Same with Sorbitol (contained in dried prunes and often used as a soft laxative) but even more toxic.