You can help curb your dog's pleasure-seeking through positive reinforcement training and by distracting him with other kinds of happy experiences. If you see him - or her - sidle up to an object/dog/person/what-have-you and begin to pant and whine in a suspicious way, the ASPCA suggests tossing him - or her - a favorite toy or asking your dog to perform a trick he or she knows and likes doing.
If that doesn't work, you may have to be more firm if your dog is insistent on mounting other dogs (which can be dangerous if a fight breaks out). Longer term preventative training can help your dog largely kick the habit. In other words, find your dog another hobby he likes to do instead ... and which he can't do while, you know, multitasking. And remember to reward your dog when he's curbed the urge.