There are several hypotheses for the widely known phenomenon of contagious yawning. One of these is physiological hypotheses is called a "fixed action pattern," which is a sequence of behavioral acts triggered by a releasing stimulus that is unchangeable and usually carried to completion once initiated. This is similar to a reflex or domino effect - if you yawn, I yawn, and so does your cousin.
Another physiological hypothesis is known as non-conscious mimicry, or the "chameleon effect." This occurs when you imitate someone's behavior without knowing it as a subtle and unintentional copycat move. Scientists believe that this mimicry effect is possible because of mirror neurons, which respond similarly upon performing and observing someone else performing an action. It is because of these neurons that we learn through observation.
The last hypothesis is psychological, and called the "empathy yawn." This is the idea that when you yawn, I might yawn in accordance to express a sense of empathy for you. Studies have shown that it is more common for people to spread yawns among friends than among strangers.