I'm on my second car ever (kept my first one running for 8 years), and I've had great experiences with it so far. Part of this was using CarComplaints.com to search which models are known for having the most issues. This was a great comfort to me mentally because it's one thing if the previous owner ran the car into the ground, it's another thing if the car was designed poorly and the head gasket routinely goes bad around 120k miles, ya know what I mean?
Generally speaking, it's best not to buy a car that was the first of its generation, as the engineers are generally trying to be intrepid to do something new. The first year tends to be the guinea pig, and the subsequent years tend to fix the problems of the first, but this is not always the case; sometimes year two gets a boost in features that don't work well, etc.
My car was the last in its generation, had the absolute fewest complaints of the 00-10 years, and I got lucky and found a seller who had a legitimate story for why he was selling.
My personal advice is to stick to cars known to last a long time, research which year you want, then hunt out either at dealerships or third parties. It takes a little luck, but research increases your odds of finding a good one.
Also learn about cars. It helps a lot to look in the engine compartment and check the suspension and know what you're dealing with :)