Just remember that all of the cars has some sort of Lemon history, like the 320i with its valve seals and the 330i with its water pump issue, the 335i with its HPFP issue, N52 motor with its hydraulic lifter ticking noise, M3 with its bearing issue
My point being, you know about it so then do a preventative measure with that and replace it before it can occur. But again, just shop around and see what there is, look at the car, maintenance of the car, and maybe get someone with a diagnostic tool and some experience too see the car with you.
None of these problems happens overnight, they come with time and there are signs to them. But yes, you are right in all of the bmw's have problems but there are people who has had no problems.
Don't let this set you off from buying the one you want, just plan for it by doing a preventative maintenance when you budget allow.