The fact is that in order to remain standing you must keep certain muscles tense, and you must be conscious to keep control over those muscles. When we fall asleep, that conscious control is sort of disconnected, and therefore we cannot remain standing. While horses may lay down to sleep, they can also doze while standing up. This is a system of tendons and ligaments that hold a horse in the standing position while its muscles relax, like a plant hanger holds up a hanging plant.
Horses also use their stay apparatus while they're awake to minimize fatigue due to standing.
In the front leg, the stay apparatus is always in place and a horse need only relax to take advantage of it. However, in order to use the stay apparatus in the hind leg, a horse must rotate its hip and literally hook one bone up over a knob on another bone. In some cases the patella can get locked in the hooked position and the animal will be unable to release it. This problem can be fixed with a simple operation.