>>30282619Dolphins, most apes and chimps, canines and felines, and some bovines have been shown to do it both in the wild and in captivity. Sometimes they use other objects or even other animals, alive or dead, to do it.
Most lower mammals can do it given the right stimulation and instruction. Some lab rats have actually masturbated to death once they figured it out.