Because horses are prey animals, it’s natural for them to want to stay close together when on the trail. Horses believe in the concept of safety in numbers and your horse feels that the closer he is to the horse in front of him, the safer he is. With that being said, a horse that follows too closely behind another horse is putting himself and his rider in a dangerous situation. The horse in front is likely to get cranky and kick out, which means you or your horse could get struck with a well-placed hind hoof.
Rather than thinking of how you can get your horse to stay back off the horse in front of him, think of how you can make it uncomfortable for him to get too close to the other horse. You’ll accomplish that by letting him commit to the mistake (in this case following too closely behind) and then putting his feet to work by doing a series of serpentines and circles until he’s paying attention to you. Then you’ll put him on a loose rein and go back to following the horse from a safe distance. Horses are basically lazy creatures; they’d always rather choose the option with the least amount of work involved. After a few repetitions of having to move his feet and sweat, your horse is going to want no part of getting too close to the other horse because he knows if he does, he’ll just have to work hard.