What happens to gunpowder when it gets wet?
In general, putting explosives in water will not prevent them from exploding, because most explosives already contain all of the necessary reactants to produce an explosive chemical reaction.  They do not need to draw oxygen from the air, and the reaction happens much too fast for the water to act as a heat sink.

Traditional "black powder" is an exception; it doesn't explode when wet.  I don't know exactly why this is, but two plausible reasons are:


Unlike most other explosives, black powder is shock-insensitive; it has to be initiated with a flame or spark.  Water can easily soak up all the heat energy from a small flame, like the one you get from a percussion cap.  This is the same as how it's harder to set fire to a living tree than a dry log, but if the fire gets hot enough it will still catch.
Black powder is a "low" explosive, meaning that the chemical reaction happens relatively slowly (for an explosion), which gives the water more time to absorb heat energy and quench the reaction.


Worse, black powder can be permanently ruined by water.  This is because it's a mixture of saltpeter (potassium nitrate, $\ce{KNO3}$), sulfur, and charcoal, and saltpeter is water-soluble.  If you get it wet enough, the saltpeter can be completely washed out of the mixture.  This doesn't always happen; the 19th century industrial manufacturing process for black powder involved deliberately dampening it, both to make it less dangerous during manufacture, and to make saltpeter crystals form inside each particle of charcoal.  But they were careful to use only just enough water.