Most modern day explosives used for military applications come in a plastic wrapper that will protect it from water for quite a long time.
The explosives themselves are very waxy so will hold together in water more than long enough for them to be set and detonated.
Explosives in bombs are encased in thick steel which takes a long time for water to rust through. Also the explosives in bombs are poured in while in
a liquid state, so there is no oxygen trapped inside the case to work at deteriorating the compound.
Old civil war era stuff like cannon balls are still fully functional even after 100+ years in the ocean, because they use black powder. Black powder
lasts for ever. Even if it gets wet, once it dries out the black powder is still good actually it is more sensitive once it dries out.