Most of the time a dog yawns for the same reason a person yawns - they're tired, and getting in more oxygen.
But they also do it voluntarily, and the traditional answer is it's a calming signal. If you watch dogs long enough, they do it to each other, when one dog is acting dominating, or aggressive, or the first dog just isn't sure (and it looks subtly different from a real yawn, if you know the dog well enough). They'll also do it during training, especially when learning something new, and if you (the trainer) is getting frustrated, or the dog is confused. They are simply trying to calm someone down - either you, the other dog, or sometimes themselves.
Here's a pretty good article about dog social skills, well worth a read: http://www.lonewolfkennels.com/calming.html
But don't overthink it. Sometimes, a yawn is just a yawn :)