You need oxygen, which you breathe in, but you breathe out carbon dioxide. If you rebreathe the same air, you’re decreasing the oxygen content with each breath. You’d suffocate yourself.
In a panic attack, the heavy breathing makes you hyperventilate. You get lightheaded from too much oxygen. By breathing into a bag, you’re not getting so much oxygen that you get lightheaded.
There’s also the issue of pressure if you are going deep underwater. a bag of air at sea level would get crushed/deflated underwater due to higher pressure. This happens to your lungs too. When scuba diving, the tanks have very compressed air, and the regulator reduces the pressure (but still more than surface pressure) to keep your lungs inflated.
Latest Answers