Why can you set off fireworks in the water without going out? What fire extinguisher can be used to put out the fire when setting off fireworks and firecrackers?

Gunpowder soaked in water can't burn. However, if the lit fireworks are put into the water, the gunpowder inside will burn out before soaking in the water, so it will not go out.

The fireworks being set off can't be put out with a fire extinguisher. If a large number of fireworks and firecrackers are put together, although the ignited ones cannot be doused with water, spraying a large amount of water can prevent the unlighted ones from burning further.