Autotrophs have it relatively easy. They can produce their own food. For most organisms, there is no such thing as a free lunch. Foraging, hunting, and parasitism are an easier lifestyle than pathogens, which must first find a host and then successfully invade. Getting past host defenses and evading the immune system are just part of the difficulties when infection is your chosen lifestyle.
Pathogens are a minority of bacterial species. Some religiously practice infection. Others, such as E. coli, are flexibly opportunistic.
E. coli is a facultative anaerobe. It can make its ATP (energy) via aerobic respiration if oxygen is present, but switches to fermentation when O2 runs low.
Many E. coli prefer the comfortable home found in the lower intestine of endotherms (warm-blooded animals). Harmless strains symbiotically benefit their host by offering vitamins in return for food.
By contrast, nefarious strains have sharper wits and no empathy for their hosts. Pathogenic E. coli dive deep into the intestines to find a favorable environment and adjust their surroundings to suit themselves.
“To establish infection, enteric (intestinal) pathogens integrate environmental cues to navigate the gastrointestinal tract and precisely control expression of virulence determinants.” ~ American microbiologist Elizabeth Melson
“Bacterial pathogens typically colonize a specific tissue in the host. Therefore, as part of their infection strategies, bacterial pathogens precisely time deployment of proteins and toxins to these specific colonization niches in their host. This allows the pathogens to save energy and avoid detection by immune systems.” ~ American microbiologist Melissa Kendall
Elizabeth M. Melson & Melissa M. Kendall, “The sRNA DicF integrates oxygen sensing to enhance enterohemorrhagic Escherichia coli virulence via distinctive RNA control mechanisms,” PNAS (9 July 2019).
“How E. coli knows how to cause the worst possible infection,” ScienceDaily (16 August 2019).