Thus, your statement, “But some anaerobic bacteria do not contain the enzyme ATP synthase” is apparently incorrect. If any bacterium is discovered without it, I would like to know about it.
In sum, all life depends on ATPase, but not all life depends on it for ATP production. Anaerobic bacteria use it to maintain pH balance instead. So ATPase must have been present in the very first cell. No known natural process could have built it up piece-by-piece, as you have suggested, because, without the entire apparatus, there is no living cell and therefore no evolution, even in theory.