Why is it that trapped gas feels like you are having a heart attack? When I pass I feel fine.

Pressure. Gas buildup in the stomach or intestines can cause pressure leading to abdominal pain, shortness of breath, leading to a feeling of chest discomfort that can give the impression of a heart attack. When the pressure is released, the feeling stops.
Can't be too sure... No one symptom definitively indicates a heart attack is or is not in progress (many people make the fatal mistake of waiting out atypical heart pain). In fact, "heart pain" is often indistinguishable from esophageal, pericardial, mediastinal, gastric, and chest wall distress. By the same token, where in your gut you retain "trapped gas" may give you very different sensations. See doctor to be sure.

Related Questions

Could trapped gas/bloating cause a burning sensation at the muscular level on left chest and inside party of left bicep? I got scared of heart attack

Go to ER. The symptoms you have listed could be trapped gas orAngina symptoms. This means that one of your coronary arteries (blood vessels to your heart) could potentially be blocked and affect the blood flow to your heart. It could result in you having a heart attack anytime. There could be other less alarming causes for these symptoms but you cannot take a risk and must go to ER without delay. Read more...