Look up VCD -- vocal cord dysfunction. The National Jewish Hospital in Denver is the #1 treatment center and must have info online. VCD can cause these kinds of things. In the worst case, the vocal cords spasm and shut completely, blocking off all air to the lungs, and of course, all larger stuff that you could swallow.
In other animals, the vocal cords function to keep junk out of the lungs. We've co-opted them for use in speech as well. But sometimes they get twitchy, and spasm like this. It's often from acid reflux that for some reason doesn't cause heartburn.
When it happens, especially with breathing, try (1) panting quickly, then breathing in very gently, and (2) puffing out forcefully, and letting air flow back in as you relax. Something about the vocal cords makes them relax when air goes out, but close up when air goes in.