As has been pointed out already, not all. HMS Vanguard was lost to a magazine explosion at Scapa Flow in July 1917. The IJN Mutsu blew up while in her anchorage in Japan in June 1943. No enemy action involved in either case.The magazines exploded due to enemy gunfire, or torpedoes. The British may have been sloppy about handling cordite, but you kind of need the ammo if you are going to fight a battle.
HMS Vanguard (1909) - Wikipedia