If I remember correctly, you yawn when someone else yawns because of some sort of primal reflex. Supposedly, you do the same things as those around you because that's what primates would do. You'd all be together, and you'd sleep at the same time as those around you, so you'd yawn as well. That's why people have a tendency to copy body language. I took a class on animal behavior and reproductive strategies, and that's where I was told this.
Contrary to popular belief, it is not because of a lack of oxygen. It has something to do with mental lapses, and seeing someone else yawn or thinking about yawning can make you yawn. You will probably yawn a lot while reading this.