Gunpowder is meant to burn at controlled rates, but traditional gunpowder, black powder, used in fireworks and older firearms typically burns very quickly. Smokeless gunpowder for modern firearms have controlled burn rates. Depending on barrel length, etc. you may want the gunpowder to burn faster or slower to affect the ballistics. I imagine they use certain ratios of differing ingredients to control the rate of burn in fireworks as well.