This is a supposed treatment for hyperventilation.
Hyperventilation is when someone starts breathing rapidly due to stress. It’s become a common trope to represent a character reacting unfavorably to something. For most people, this is rare.
When someone breathes too rapidly, this lowers the carbon dioxide level in their blood, which causes the blood vessels to their brain to constrict. This causes symptoms like dizziness and tingling, which can induce panic and increase breathing, leading to an vicious cycle.
Breathing into a paper bag is supposed to calm hyperventilation by forcing someone to breathe in their own carbon dioxide output, thus increasing the level in their blood and alleviating the symptoms.
There is little evidence this actually works, except perhaps as a placebo.