Thermal runaway is one issue, and can be a result of various circuit faults, a lot of which where due to internal faults from QA issues on cheaper batteries, or from some mechanical damage in things like phone from them flexing. Some of them were happening because the charger circuits were failing and they were overcharging, damaging the circuits, and eventually failing catastrophically.
And to make life more fun, the fumes coming off of it are usually combustible and toxic, so it can build up to explosive levels and light off, while also poisoining anyone in the vicinity. So part of the safety considerations is the compartment size the batteries are in. Sometimes that goes into a small water tank to basically absorb the gases while hopefully cooling things, but it's not really meant for something like a submarine.
Pretty uncommon now, but some of the lithium metal batteries would actually be class D fires. Even the normal ones that turn into a class A fire is really messy though as it's somewhat self sustaining and pumping out incredible amounts of heat, so you are doing less 'fire fighting' than cooling the heat. Fire departments are reporting it takes something like 4 or 5 pumper trucks of water to control an EV car battery fire, which obviously always isn't available.
It's pretty complicated, because there are a lot of different types of battery chemistries, with some proprietary types, different ways to set up the cathode/anodes etc. And with some pretty major fires on container ships from them, some of them are almost unsellable because no one will actually ship them due to liability.
You can also get things like really dramatic shorts from shrapnel damage, and with li-ion batteries that can be a pretty dramatic explosion just because of the power density. I remember seeing a test on laptop battery, which I believe was a stacked plate type arrangement, and there was a bright white flash as it turned into plasma with a pretty good blast, and then bits of it burning flying around the test chamber.
With the wet cell lead-acid batteries, they have their own hosts of risks, including things like hydrogen off gassing building up, violent reaction with sea water etc, but they are pretty stable and have good cycle/recharge characteristics. The whole stability thing for subs is really complicated as well, as they need to think about neutral buoyancy and balance, while trying not to get crushed, run into something, and stay quiet. They are a special breed.
One of those things where the technology was introduced, and the safety regulations are being figured out after the fact. Less because people didn't know, and more because the energy density provides huge benefits, it wasn't until there were some pretty major issues that the response went from 'Shut up, nerd' to 'what are the options to make it safer'. But because there are a lot of really sketchy products already sold and in use, it's a challenge. It's annoying as hell as well because people want a simple rule of thumb, which is only possible if you are really restrictive (or an idiot).
Our organization is great at saying they want evidence based decision, right up until the evidence doesn't support their previously decided upon COA, or doesn't exist because no one has ever done the research (and then won't fund testing).
Sorry for the rant, this one has eaten up a lot of my life in the last few years, and get a lot of flak from every side for trying to be reasonable and find the middle ground.