It's not the bacteria, it's their by produce, like lactic acid that you want to avoid.
Unless you keep the wort hot (>150) you can get an infection.
If you raise the temperature to > 160, to pasturize it, the risk is as it cools, and cold air is sucked in, bacteria will get in.