This is because when you hyperventilate, you are getting rid of a lot of the CO2 in your body. CO2 buildup is one of the causes for you feeling pain when you hold your breath too long. By getting rid of it, you delay the body's need to breathe for longer.
However, this can also be dangerous. Hyperventilation reduces the level of CO2 but does not particularly increase the level of Oxygen in your bloodstream. This means that you may run out of oxygen but because you don't have CO2, you won't feel the need to breathe and you may pass out!