In 3 years of brewing I've only ever had one infected batch, and I'm 95% convinced the cause of it was a dirty ball valve on my brew kettle.
Up to that point I'd gotten pretty lackadaisical with doing a thorough cleaning of that valve because after a few dozen batches it never seemed to cause a problem, and because I assumed that the exposure to the heat during the boil would do a good enough job of sanitizing it.
It was a 10gal batch, split into a pair of 5gal buckets. On bottling day I was disheartened to see that both buckets had developed an infection. If it were only one of the two buckets with an infection, there would be multiple possible causes -- maybe that particular bucket was poorly sanitized, maybe something was introduced to only that bucket when pulling gravity samples, or whatever. But since both were bad, I had to take a look at what common factors would be in play on the cold side for the entire batch of beer, and pretty much the only things I could come up with were the brew kettle itself post-chill, and that valve (I don't even use tubing when transferring from kettle to fermentors; I just let it gush out the valve into the buckets to help oxygenate the wort).
I remember when I brewed the infected batch, it was after a period of a few months where my gear had just been sitting idle, so that probably gave a bunch of germs a chance to take up residence in the valve. I disassembled it to have a look, and sure enough, it was pretty gross. I thoroughly cleaned it, and now I have a second ball valve on-hand so I can swap them back and forth to always be sure I have a perfectly clean one ready to go on brew day.