The stifle joint on a horse or mule or donkey is much like the human knee - it is where the femur meets the tibia, and the patella glides across the front of the joint. Equines are supposed to be able to lock the patella at rest. When you see an animal standing with one hind foot cocked and resting, then the patella on the other side is locked on top of the tibia. This allows the animal to stand using very little muscular effort.
The patella is not supposed to lock while the animal is in motion, however, and when it does it is uncomfortable. The motion of the stifle joint stops suddenly until the patella unlocks, and this can produce a sensation for the rider of the hind end of the horse falling out from under them. Sometimes, the patella won't unlock, and the animal will be stuck dragging the leg out behind. This is definitely a scary-looking situation, but it is generally easily remedied by asking the animal to back up, which nearly always releases the patella.
Locking patellas can be caused by very upright conformation or by weakness of the quadriceps muscles. The simplest therapy is to strengthen those quadriceps, best done by lots of long, straight, trotting and work uphill. Small circles, such as on a lunge line or in a round pen, make it a little more likely that the patella will get stuck and should be avoided when trying to rehab an animal with this problem.
If increased conditioning doesn't fix the problem, then sometimes a veterinarian may inject the patellar ligaments. This causes irritation and causes the ligaments to tighten down, reducing the likelihood that the patella will catch when the leg is in motion. It does not prevent the patella from locking at rest as it should.