Let's be clear; mounting is a common behavior among dogs. Puppies, older dogs, and even female dogs do humpie. It's also the behavior that dog owners find very embarrassing. Most people think humpie is a sexual behavior, and it can be. However, since neutered male dogs, females, and even puppies engage in mounting, it's clear they do it for a variety of other reasons. Some are listed below.
Gaining social status
Attention from their people
Given the above list, you can see it's often an enjoyable behavior for your dog. That makes it self-reinforcing - it's fun! Although it's a common behavior, many dogs do not like to be humped. They will take offense at being mounted and start a fight with the overly friendly dog. So it's in your dog's best interest (and will save you loads of embarrassment) if your dog doesn't engage in humpie.
Can stop your pooch's humping behaviors?
The short answer is yes. You must be consistent with your dog to get them to knock it off. Any vet will tell you that the earlier you stop this behavior, the easier success will be.
If you have a puppy who starts this behavior, don't encourage them by laughing but immediately stop the action and substitute something else for it. They most likely are over-energized and need to burn off energy, give Fido a toy, or toss a ball for them. They will need an alternative to humpie.
If you have an older dog engaging in this behavior, it has probably become a habit; it may take a bit more work to discourage. Obedience training helps keep excitement levels down and teaching your dog the "leave it" or "off" command will help too. Again, give your dog something else to do. If you tell them to "leave it" and they obey, have them sit and reward them for paying attention - perhaps a tasty treat, a toy, or affection from you. Remove the humpie target if possible.
If humping has become a seriously ingrained behavior or they do it compulsively, you may need some help. Try a trainer or behaviorist to help convince Fido that there are some excellent alternatives to this behavior.
Hang in there, remind your dog every single time that humpie isn't a suitable thing to do - soon you'll have a more socially acceptable pup!