Without having ever seen the horse, here is my take on the situation. Horses are a prey animal who MUST have a leader they look to in order to feel safe and confident. Hopefully, you are that leader for your horse.
However, often times as we trail ride, we begin to visit with our riding buddies, or maybe start daydreaming or gazing at the scenery. We stop focusing on our riding and our horse. Our horses can tell when we are not paying as much attention. They start to think, "Uh-oh, my leader isn't keeping an eye out for predators. I better take over keeping watch." The next thing you know, you're heading for a wreck.
Had you been paying closer attention to your horse, you might have seen subtle clues that things were starting to go downhill. Either way, the solution for this is the same. Change things up. That's right. Change things up. Give your horse something else to think about besides whatever might be lurking in the next bush.
Every 100 ft or so, ask the horse to do something different. Instead of just following the trail straight, do zig-zag lines across it. You'd be surprised how resistant many horses are to leaving the trail, especially if they are following another horse. Make a circle around a tree or step over a dead-fall. Go faster. Go slower. Go faster or slower within the same gait. Ask your horse to maintain forward momentum while tipping their hindquarters out to one side or the other. It can be as simple as cuing your horse to follow the bends of the trail instead of just allowing him to amble through the curves. Be mindful. Use your imagination.
If you practice these types of changes often enough, you won't have to think about it, you'll just do it as you carry on your conversation or bask in the beauties of our world.