This type of indiscriminate humping isn't about mating.Even a dog who is frenzied by hormones knows the difference between a receptive partner and someone's leg.
Problem is, some dogs aren't very selective about the objects of their affections.
They'll try to hump arms, legs, teddy bears, sometimes even cats - usually with disastrous consequences.
Neutering a dog or spaying a female is a big decision.
It, in and of itself, is not a cure for anything - other than the prevention of tiny little paws appearing sometime down the line. If the dog pesters for attention, it should be given a command before any reward of spoken praise or petting.
Sexual mounting has been successfully treated in many cases by neutering the offender.