If you buy a car using a loan and realise it's faulty, you'll need to take it back to the dealer, and ask it to repair the problem. The dealer has a responsibility under the Consumer Rights Act to ensure the car is as described and fit for purpose.
If there's something obviously wrong with the car, avoid taking delivery. If the fault develops later, contact the dealer and ask for a repair or replacement.
However, if you've bought from a private seller, you've fewer rights, so ensure you take the car for a test drive before committing to buying it. Our Buying a used car guide can help with what you should be looking for.