Not all animals yawn, if only because many large groups of animals lack the basic anatomy necessary for yawning. Tapeworms, for example, are parasitic animals that absorb nutrients through their skin, according to HowStuffWorks, and therefore lack a mouth.
Though the exact trigger for a yawn is not known for sure, the behavior has been observed in many vertebrate animals, according to WebMD. Many species of fish, such as Japanese fighting fish, yawn to intimidate rivals. Other fish gulp air when swimming in oxygen-poor water. Dogs have been known to yawn in response to seeing their human owners doing it, as well.