When it comes to male dogs mounting each other, it is purely about dog dominance and not in any way sexually related as some people may think.
Dogs persistently attempt to gain dominance over one another, whether male or female. It is part of their instinctive behaviour that when two dogs meet, they will use eye contact to observe the stature of one another. If one submits by lying down then the question of which one is dominant over the other is settled. If not, dominance is achieved by the dogs trying to mount each other until one rolls over and turns away. Until the eyes have completely turned away, surrender has not happened as the ‘losing’ dog may launch a sneak attack against the other.
When complete surrender is achieved, the mounting behaviour becomes a dominance display – the one on top reminding the other who is in charge. Because the head is the highest part of the dog, when one dog brings the head of the other dog down, it is a show of who is higher and in control.
Male dogs can also mount each other because they know each other very well and may have been separated for a period of time. This kind of dog mounting is a form of bonding and is not solely associated with males fighting for dominance or trying breed like a male/female.
It is also not unusual to find that a male dog may release his scent on the other dog to proclaim to other dogs that he has won the battle over the dog he has mounted.
Because this is an instinctive nature and behaviour of a dog, the behaviour should not be tolerated and it is better just to leave the dogs alone.