Since this question comes up all the time and I remember answering it years ago, I've decided to have another go:
Be meticulous and cautious. Do not buy a modified car.
First use common sense to rule out the worst offenders: does the VIN come back clean? Was the car at the bottom of a lake, stolen, or burned? How many pieces is the car in?
Once you have a basic understanding of the car's history then:
Only buy a car with FSH (Full Service History) in the form of a logbook and original receipts in the owner's name from an authorized dealer or repair facility (no independents for the FSH on such a new car).
Take it to an independent specialist and have them do a compression test, check the turbo shaft for play, check the brakes and clutch for wear, and pull 100 ml samples of motor oil, gearbox oil, and coolant - have these analyzed by an independent lab. Ask the owner what brand lubrication/cooling products are in use - if you get a blank stare or BS, do not buy the car. If you get an answer, send the samples in for testing and use your own fresh fluid (same type indicated by owner) to replenish the car if needed.
Have the mechanic comment on the plugs while they are out.
Have the shop pull any ECU codes. If no codes, check the battery terminal for wear indicating it's had contact with a wrench - if the FSH doesn't indicate any reason to pull off the terminal, the ECU codes may have been blanked by the owner. Ask and depending on the answer, decide... What's that you say -- the battery is new and that's why the terminals have wrench marks? When did the original battery fail, why, and where's the receipt again?
Find a body shop and pay a body repair person to take a look at the body and tell you if it's been re-sprayed and if all the seams are original, and if any panels have been replaced.
Check the condition of the driver's floor mat. It should not look ancient in a car with low mileage. The usual pedal cover check doesn't apply, as these are metal. Check the wheels/rubber for ridiculous wear that doesn't correspond to the driven-by-granny-to-church-only story you may have heard.
Check the body for nicks and damage to the paint. If the car only has a few miles on it, were they all done following a gravel truck down the road or has the owner simply replaced the instrument cluster with another showing more favourable mileage?
When were all the recalls performed? When was the radiator replaced, the clutch judder fixed, and the driver's seat rail bolt replaced? By whom?
Do not buy a car with a spotless engine bay. Find a nice dirty one. Look for streaks of fluid and/or other leak signs. Look for juice marks on the tarmac where the car is usually parked. Check the exhaust component bolts from the manifold all the way to the muffler, turbo and up/down pipe included of course, and see if they've ever been removed. Check the story.
Are the dampers still firm and the steering tight or does the car wander and float? Why?
Look all around the car and inside the engine bay for anything that looks out of place or that doesn't agree with the image a machine put together at a factory by pros and robots would portray - signs of an aspiring "tuner" should make you run.
This will take time and effort, and will not be free, but it will ensure you'll have a fighting chance of getting what you think you're getting. Don't rush to buy a car, it's simply not worth it. This is a Subaru, they make them every day and you'll find another soon enough. Rushing costs money.