Usually, we yawn when we are tired or bored and probably breathing slowly and not very deeply. Then the brain's automatic control of breathing will trigger a deep breath. That's what we call a yawn.
This automatic control works from a spot in the base of the brain. Its job is to keep checking on the carbon dioxide in the blood. When there is too much carbon dioxide, the control speeds up our breathing to help take away the carbon dioxide.
It may seem strange to think that our breathing is controlled automatically. We can think about our breathing and decide to breathe and decide to breathe rapidly or slowly. But most of the time we do not think about how to breathe, and the automatic control does the job.