According to a New Scientist article a few years ago, it’s actually the opposite. Yawning before sleep is a way to try and stay awake. So it being catching makes sense; if others around us need to stay alert for some reason, we probably do too.
"Why then do we yawn? To ready our brains for switching gears, says Ronald Baenninger, a psychologist at Temple University in Philadelphia. Baenninger asked people to wear motion-sensing wristbands as they went about their normal routines and to hit a button on the device whenever they yawned. After collecting data for two weeks, Baenninger found that yawning tended to precede periods of activity. Within 15 minutes of yawning, his subjects were generally engaged in some form of hustle or bustle.
There is also plenty of anecdotal evidence that yawning helps the brain to gear up for something big, says Provine. Olympic athletes yawn before a competition, paratroopers yawn before their first jump, undergraduates yawn before final exams, and violinists yawn before a concert. “I’ve never seen so much yawning as before a marathon,” notes Baenninger. And it’s not that the runners, jumpers and virtuosos are tired or bored, he says. They’re simply working to maintain a certain level of physiological arousal, so they’ll be prepared for the main event.
“We yawn in situations where there is nothing to stimulate us, but it would be bad to lose the level of arousal,” Baenninger explains. "