You are having hyperventilation.
Hyperentilation attacks are caused by stress and leads to a feeling of breathlessness. This in turn causes you to take deep breaths or feel that you are not able to breathe. This is a form of panic attack.
Steps you should take for this are:
Recognise that you are having a panic attack and thats all this is - this is the first and most important step.
Close your eyes and lie down.
Take deep breaths - breathe in for a count of 4, then hold your breath for 1 second, then breathe out for a count of 4, hold it out for 1 second, and so on.
Muscle relaxation: clench your muscle groups tightly and then relax. First clench the muscles of your foot, then relax them, then the calf, thighs, hips, abdomen, chest, hands and face. Do this repeatedly.
Mindfulness: meditate and pay close attention to all the sensations on your body - the clothes on your body, the air of the room, the sounds you are hearing.
These steps will gradually help you to control the panic attack.
At the same time, you should also consult your doctor once if you have not already and ask for lung function tests to ensure that you have normal lung function.
You should also discuss with your doctor about taking anti anxiety medicines, you need anti anxiety medicines to overcome this.