Breathing into a bag prior to holding your breath can increase the amount of time you can hold your breath. This is because the act of breathing into a bag increases the amount of carbon dioxide in your body, which in turn triggers a reflex that slows down your breathing and heart rate, making it easier to hold your breath.
When you breathe into a bag, the increased CO2 in the bag and in your lungs causes your body to retain more oxygen, allowing you to hold your breath for longer.