There are a couple of reasons why your dog could be doing this and the first is that he is a young dog and he has a lot of hormones. It is extremely common for young dogs to hump absolutely everything. Whether that be a person, a tree, their toys, or even other dogs of the same sex! This is sexual frustration due to hormones and it is perfectly normal.
On the other hand the mounting of other male dogs could be a dominance thing. Male dogs may hump another male dog to show them that they are in charge. There is nothing sexual about it and it means nothing other than 'I am the boss and I am in charge of you'. It can be a particularly embarrassing problem and sometimes even castration will not stop it. The trouble is, as the dog reaches adulthood, if they are still doing it, it is likely to be more of a habit than anything else. Habits are hard to break so you will need to seek the advice of a trainer to sort it out.
On the other hand the mounting of other male dogs could be a dominance thing. Male dogs may hump another male dog to show them that they are in charge. There is nothing sexual about it and it means nothing other than 'I am the boss and I am in charge of you'. It can be a particularly embarrassing problem and sometimes even castration will not stop it. The trouble is, as the dog reaches adulthood, if they are still doing it, it is likely to be more of a habit than anything else. Habits are hard to break so you will need to seek the advice of a trainer to sort it out.