I’ve been in this business and observing dogs together for over 10 years . The social behaviour of dogs is complex. So much so that experts spend lifetimes studying the language and social structure of man's best friend.
Being in a business that includes many types of dogs together everyday, I have watched dogs hump eachother and objects innumerable times. This article: https://www.aspca.org/pet-care/dog-care/common-dog-behavior-issues/mounting-and-masturbation pretty much sums up what I myself have observed.
This one is obvious and can happen with males intact or neutered. Earlier this year we had a rescue neutered male. Like most people I thought that when a dog is neutered they lose their desire to mate. Not so! I phoned my vet and had that awkward conversation – why is my neutered male humping a female in heat? The doctor explained that sexual feelings are complex and hormones are not the only factor to consider. Body language and scent can also “turn on“ any male dog.
When both male and female dogs hump other dogs, same sex or opposite, they can simply be playing. It’s like two kids romping around and competing to be “king of the mountain”. Healthy play behaviour is when both dogs trade off being the top dog. This is not a problem unless one dog doesn’t like it and the other keeps trying. In this scenario a dog fight could occur. You need to watch how they react to eachother and determine whether or not the play humping is okay with both dogs.
When a dog gets excited meeting up with another dog or person, he/she may express happiness via humping behaviour.
Humping can become a compulsive problem. Probably a sign of stress or anxiety. Your dog may mount another dog, a toy, blanket, or a pillow. This is only a concern if the dog is obsessive about it. This type of obsessive humping requires a dog behaviorist to evaluate the dog and find ways to relieve the dog’s stress and anxiety.
If your dog seems pre-occupied all the time with humping, he/she should see a vet to make sure there is nothing physically wrong such as urinary issues, skin allergies, etc.
If only one of the dogs in a pair is humping, it could be a dominant act. There’s no need to be concerned if the other dog doesn’t mind. You need to watch the body language of the dog being humped. If the dog on the bottom seems nervous, submissive or showing signs of aggression then they both need to be separated to avoid a possible fight.
I highly recommend visiting this site: ASPCA.org for more detailed information