There is always an element of risk involved when buying any car, but especially if it is second hand. If you buy from a reputable car dealership you may get a warranty but the warranties are often quite limited and do not cover as many things as you may first think, they also may only last for 3 months after which time you have no comeback should the worse happen. If you only get a three month warranty from a car dealership you can often pay to extend this warranty and there are third party companies that offer warranties to consumers regardless of where they bought the car from.
It is strongly recommend not to buy a car blind (that you haven’t seen) unless buying it brand new as any second hand car should be seen and ideally driven as often you will not notice faults until you come to drive it. Ideally you would also want to have a used car check carried out on the vehicle and a HPI check, some dealers do this as standard others will not so you may have to pay a company such as the AA to do this for you. If you are buying privately then always do a HPI check as it will show you if the car has been in an accident, reported stolen or has outstanding finance on it.