The mind and the body are co-dependent. One cannot live without the other, and they are so entwined that one cannot do something without the other half knowing. When you have a panic attack it is because something has distressed the mind and it has informed the body of this.
To see how this operates it is useful to be aware that we have three distinct parts of the brain; a model that was coined the "Triune Brain" by Paul D MacLean in the 1960's. The three parts are known as the Reptilian, the Mammalian and the Neocortex. The reptilian brain, the oldest of the three, controls the body's vital functions such as heart rate, breathing, body temperature and balance. These are the parts we are not conscious of controlling- We don't have to order our stomachs to digest food for example, or tell our hearts to beat. Our reptilian brain includes the main structures found in a reptile's brain: the brainstem and the cerebellum.
The next part of the brain to have developed is the limbic brain, which is considered to have emerged in the first mammals. This consisits of areas including the septum, amygdala, hippocampus, the thalamus, the hypothalamus, and the cingulate gyrus, which are of particular relevance to the processing of memory.Theses parts were found to be responsible for motivation and emotion involved in feeding, reproductive behaviour, and parental behaviour.
The third part to evolve is the Neocortex, which is only found in higher mammals and humans. This allows us our rational thinking, appreciation of the arts, abstract thought, perception language, and planning.
It is in the limbic system that we determine our emotions and memories, and as we experience situations the amygdala is busy assigning the event an emotion:-let's say we are sitting under a chestnut tree in a park on a hot summers day and we see someone giving us a beautiful smile and telling us they love us; then this may be interpreted as a lovely thing and we feel joy. Close to the amygdala is the hippocampus,and this organ puts the event in a time frame (let's say it happens to be midsummers day). These two bits of information are linked together and stored away as a memory.
Now, if this time the event is something far more unpleasant, for example, you're walking home alone at night and as you walk down an alleyway you hear someone coming up from behind you and walking faster and faster towards you, they start to run and then you feel them touch you. Your amygdala interprets the signals that are fed to it (e.g. what you perceive with your eyes, ears, and sense of touch) and interprets that as a dangerous situation, even life-threatening event. It allocates the emotion of fear, and immediately this is sent off via hormonal messages to your adrenal glands which pump out adrenalin. The adrenalin tells the sympathetic nervous system to help you get out of danger - the hormones go to various organs in your body to prepare you for running away or fighting; so your heart beats faster, your breathing gets quicker (to ensure you have enough oxygen to fuel the muscles that you are going to use to stay safe), your eyes dilate so that you can see as much as possible to help you make decisions as to where to run to, the blood supply to your stomach is shut down (you really don't need to be digesting your dinner right now!) and your bladder will relax (or even empty). Your body is sending all the energy to where it is needed to help you stay safe. You don't have to tell it to do these things.
The person rushes straight past you knocking you sideways and shouts out a hurried apology as he continues on down the alleyway and runs off down the main street out of sight. When you feel safe again, your body will send a message to the adrenal glands to pump out cortisol, which kicks the parasympathetic nervous system into gear, and reverses all the bodily reponses I just mentioned; your breathing and heart beat will slow down, your vision and hearing will go back to normal, etc. All is well. You may be slightly cautious now the next time you walk down an alleyway, but probably wouldn't avoid it all together.
Now what if this time the situation is different.This time the man grabs you from behind and holds a knife to you. He is much bigger than you and you have no choice but to hand over your wallet and phone. You notice that he is tall and is wearing a black hooded jacket so that you can't see his face. Because you are in a terrifying and traumatic situation you may not be able to fully process this event completely. The amygdala won't be able to fully process this and it is as if the event gets stuck in the mind and body.
Even once you are safe again you may find that certain situations trigger you into having a panic attack. This is because little details of the trauma have stuck with you; and this may be conscious or unconscious details. So you may have a panic attack when you next walk down an alleyway, which you would probably understand, but you may also have a panic attack when you see someone wearing a black hooded jacket (even if you didnt realise that you noticed this detail at the time of the attack).
The bmind still treats these bits of information as current signs of danger and activates your body to try to prepare you to make yourself safe. Panic attacks are horrible, and it will help you to remind yourself that it isn't dangerous for you- you won't have a heart attack or collapse. Breathe calmly and tell yourself that you are now completely safe.
One sure-fire way to stop them is by breathing out for longer than you are breathing in- so let's say you count to 4 as you breathe in, then you need to count to 5 or even 6 as you breathe out. keep doing this for a good minute or two and it sends the message to your body that you are safe, and stops the adrenalin being pumped around.
A trauma therapist can also work with you on the causes of the panic and help you find ways to realese it - as will an EMDR therapist. You don't have to continue to suffer.