If your horse is pulling the reins out of your hands by putting its head down suddenly, your horse is likely doing something called 'rooting'. Canny school horses can learn a few evasion tactics in an effort to get out of work. Rooting is just one of those tactics. It's sometimes done by school horses to evade the rider's instructions by making them lose contact. They rarely do this with an experienced rider because they know by the confident leg and seat aids of their rider that they won't get away with it.
But, because many beginner riders don't know how to cope with rooting, horses quickly learn that putting their heads down and pulling the reins out of the rider's hands is a good way to go the direction they want to like the nearest patch of green grass or the barn door. Some horses are very quick at dropping their heads and either pushing their noses out or turning their heads quickly, so that if the rider has a tight grip on the reins they get pulled forward out of the saddle. Or, it just plain hurts when they pull the reins through your hands. This is a good reason to wear riding gloves too, as they'll protect your fingers.
What to Do When Your Horse Is Rooting
When it comes to playing tug-of-war with a horse, the horse will always win. They are just stronger than us. That's why pulling on the reins doesn't work. Pulling hard when a horse roots will hurt the horse's mouth and eventually make him more insensitive to rein aids.
The trick to dealing with rooting is not to pull back on the reins, but to ask the horse to keep moving forward. As soon as you see the horse starting to put its head down to root, push it forward with your seat and leg aids. This should bring the horse's head up, and make it easier for you to keep the reins from slipping through your hands, or re-organizing if they do get pulled.
It shouldn't take long before the horse realizes that this tactic isn't going to work with this rider, and the horse won't try it all. (They'll remember to use it with a rider that doesn't know how to cope of course!)
You have to learn to recognize the signs that your horse is going to misbehave either to root or sneak a snack of grass. Often it happens as you pass the barn door or the gate. But if you watch your horse, you'll quickly learn when the behavior is about to take place. As soon as you sense the horse is about to put its head down to root, use your seat and leg aids to tell it to walk forward.