If you are looking to buy a used car then there is always an element of risk. You may be buying a car off a complete stranger and have no idea of the history, if it has been looked after or even if the mileage is accurate. Even when buying a car off someone you know and trust, they may not be aware of an outstanding issue so there are still no guarantees.
Ideally you want to try and buy a car with a warranty. This will probably cost you more than buying from a private seller but can give you a little extra piece of mind. When looking in to the warranty, be sure to check what is covered as some, do not cover half of what you expect hem too.
You can of course get a used car check carried out on the vehicle by a third party, prior to buying it. Again it is not 100% guaranteed to pick up on any issues but will check the most likely parts that fail and known issues with that particular car.