Bring someone knowledgeable with you, if possible. This doesn't mean you don't have knowledge, just someone else might have more. For example, if you're buying a thoroughbred, bring someone who has good knowledge of thoroughbreds. If you're buying something for showing, bring someone who shows. I've worked in a dealers yard for ten years, but I'd still take someone with me to buy a horse if they knew more about a certain breed or discipline.
Check if the horse matches the advert. If the horse is advertised as having no lumps or bumps but has a clear swelling on its neck, walk away!
Give the horse a basic health check. Check it's not too thin. Check the back and girth area for obvious signs of pain. Check the eyes for any discharge, but also check for dullness which may indicate the horse is doped. Check feet for any corns or obvious issues. This will also let you know if the horse's legs can be lifted. Check the nose for any discharge.
Watch the horse be tacked up and have the owner/rider ride the horse first. When you get on, do your basic walk, trot, canter, halt and circles. If you are buying a horse for lots of trails/hacking, then ask to be taken on a hack. If you are buying a horse for jumping, ask to go over a small jump. Look out for any signs of discomfort from the horse, lameness, or a reluctance to move. Also, check if the horse actually suits your riding style. It's okay not to click with a horse.
If you can, have a trial period. It's more common now to have the trial period at the owner's yard so be prepared for this. Unfortunately, too many people taking advantage of trial periods means it's rarely at the potential buyers yard anymore (horses coming back lame, injured, starved etc). Many places will let you take the horse to a local competition though, with supervision.
Get the horse vetted, regardless of what horse it is and what you're doing with it.
Trust your gut. If your gut is telling you there's something not quite right, then walk away.
Don't rush into it. There's plenty of horses out there, and there's one that suits everyone. It may be the first horse you try, it may be the 20th.