Have you ever gagged when you weren’t really choking?
Sensing
This happened to me while getting a molar fixed at the dentist. The assistant must have touched her instrument to the back of my throat, which my cranial nerve nine (CN IX) sensed. If it had been the back of the roof of my mouth (soft palate) or the uvula, the trigeminal nerve would have been responsible for the sensory information, but the reaction would have been the same.
Individuals vary in their sensitivity, but usually for any one person, the response is usually consistent. Sleep deprivation can make you more sensitive to gagging. Babies can be especially sensitive to swallowing chunky food if they have a sensitive gag reflex, which may last until they are about six or seven months old. Some people remain extra sensitive throughout their lives, while other people may not have a gag reflex.
Responding
Psychological factors can also come into play, like when something really grosses you out; but I won't get into disgusting triggers today. Gagging in response to something physical is a true reflex, meaning that only the brain stem is involved. So after my brain stem received the signal that it thought something was blocking my airway, it sent out a response though cranial nerve ten (CN X), which told the back of the roof of my mouth to push up and the pharyngeal muscles on both sides of my throat to contract.
Solving
The hygienist suggested that I concentrate on breathing through my nose to help with the gagging issue. This seemed like a simple thing to do, but it did make a difference. It also seemed to make sense to keep breathing from a survival point of view. Now when I brush my teeth, I also pay more attention to breathing, so that I don't make myself gag.
Other suggestions for reducing incidences of gagging at the dentist, that don't require special equipment include focusing your attention on keeping a foot raised while you're reclined in the dentist chair or humming (because you can't gag and hum at the same time). And if you practice brushing at the edge of the sensitive part of your tongue, you can become less sensitive to gagging.
If it's an ongoing issue for you, speak with your dentist about it.