(I hate talking about this subject lol)
When you have panic attacks, on evolutionary terms, it's a way to escape from a perceived threat, ie. the flight end of the fight or flight mechanism. All the things you feel have a logical explanation in caveman days, but in our modern society the mechanism has remained and become outdated. We're rarely ever in any serious danger these days.
When you gag or vomit it's because your body stops digesting food and wants to get everything in there out as soon as possible. This is to conserve energy to run away from your threat. Also, if you vomit, you look less attractive to predators