The shot of adrenlin released into your body by anxiety causes the heart to race or bang, the more frightened you become by this sensation the more adrenlin is released and the longer it continues.
Why we wake up with panic, I find that had to understand also, but I too have spent many nights afraid to sleep cause I didnt want to wake up with an attack again.
My theroy is that once the conscious mind goes offline the subconscious takes over and whatever problem we are currently facing comes out in our dreams, or in night panic.
I have found that if I write in my journal right before I go to bed that it really helps to empty my mind of all these thoughts that disturb my sleep.
I am not an MD, therapist or anything, but I do know that sometimes writing down whatever thoughts are running thru my head right before I go to sleep, no matter how scattered they are, does help alot.
If I wake up with a PA i usually will breathe and then try to meditate until I go back to sleep, sometimes this takes an hour or more before I can relax and sleep.