Whence fecal E. coli (et al.) if swallowing it is dangerous?
E. coli is mostly harmless; only a few strains are harmful.

I don't believe the route by which gut biota is established has been entirely established for any species but, for example, koala feed their faeces to their offspring to help them establish biota capable of digesting eucalyptus. It seems that a small proportion of ingested bacteria somehow survive passage through the stomach to the gut and then begin multiplying and colonising the intestines.

It's also important to realise that just because an organism is sometimes harmful doesn't mean it always is. There are many microorganisms that are pretty much ubiquitously found on or in your body which are capable of causing disease but only do so very rarely; usually when the body's defences have already been compromised (e.g. Pseudomonas aeruginosa, Candida albicans aka thrush, and so on).