This is a broad question and there's a great deal of variation in how I'd approach this. So I'd like to start this answer with this caveat:
Always Safety First with horses.
Horses are large, powerful creatures and although they are prey animals and more inclined to flight than fight, they can still inflict a lot of harm on a human being, so I'd not advise people with little horse experience to interact with horses they do not know or without the owner or an experienced horse person present.
How to Stop Horses from Biting
Prevention is better than cure
Generally I maintain a guard up with any horse I'm interacting with as potentially able to bite me. Women (I don't know where this is for men) most frequently get bitten on the chest, which gives an indicator of how they make themselves vulnerable to being bitten. It would indicate they are using their arms - probably outreached to the horse and exposing their chest.
I never entirely trust most horses, as they cannot speak and if they are annoyed it is one of the ways they have of telling you to "get lost". So I'm always mindful of their body language and maintaining a defensive position, so I can defend myself should a horse attempt to bite. Many people will miss the subtle body language that a horse is irritated or threatened.
So other than keeping out of biting distance of a horse, the best way is to keep an arm across your body to intercept any possible bite.
If a horse tries to bite or does bite
The key to this, is timing. This requires an immediate response so the horse is clear what it is you are reacting to.
If a horse goes to bite me, I bring my arm up and block the bite in a way that the horse cannot bite me arm. It will usually involve a swift, sharp (not hard or brutal) slap to the nose. That's my way of saying, don't think about it. Many people view this type of correction as "mean", but if you look at how horses treat each other, they will make it clear to a horse beneath them in the herd it's not ok to try and bite.
Biting and the young horse
Young horses, foal and yearlings, horses that still clack (which is a sign of submission), are more prone to biting humans. They are not being bad, they are learning how to interact with the world. This is something that needs to be discouraged. I have found that young horses will only require one or two decent corrections and correct handling to learn that it's not ok to bite their human. This may not translate across to all humans.
Horses do not treat humans equally
Horses take each human as they find them. They are herd animals that relate to one another continuously on a ranked system or pecking order. The stronger animals lead. The continually test each other for strength and dominance, it is how the herd survives. The lead horse will move the other horses, they can rely on that horse to save them from predators. They listen to the horses higher in the pecking order. The higher horses will move the lower horses. Basically the horse that can make another horse move, is higher in the pecking order. They are the same with people.
A horse may regard itself as higher than a human and there's a good chance it may if it's biting the person. This puts that person at high risk of being hurt if they challenge that horse without experience. This is an example of how a horse that believes it is higher than a human and has bitten the human, will react when the human doesn't understand horses.
When a high horse is challenged by a lower horse, it will up the anti until that horse brings its behaviour into line and does what the horse wants it to. Now the horse is not being mean, it's directing the other horse, for its own welfare. It's important the herd reacts when in danger and reacts immediately to the lead horse.
It's a good idea to have something with you to create distance with a biting horse. A lead rope that you can swing works well.
Teaching horses not to bite is a part of the overall handling of the horse and most of it comes down to ensuring the horse knows you are the herd leader.