Most battery explosions occur in batteries at or beyond "end of life". It is most often caused by the positive and negative plates coming in contact with one another. This can happen from the batteries being of overly cheap construction and / or using poor quality separators. Sulfation and plate warping can also lead to this. Thermal run away can also lead to explosions. Chargers with battery temp sensors can help minimize this risk..
Batteries not sufficiently charged to full regularly, or stored & charged in temps above 80f can and will sulfate more quickly. Heat is one of the worst enemies of batteries. Sulfation causes the plates to wear and degrade. It also prevents current from flowing into and out of the battery as it should. The plates are not always evenly covered in sulfate so "hot spots" can develop in the plate which can lead to warping.
Due to vibrations on a boat or the process of equalization the lead sulfate can shed or fall off the plates into the bottom of the case. Automotive type batteries such as 12V group 24, 27, 31, 4D & 8D, have shorter cases and less room for lead sulfate to accumulate. 6V deep cycle batteries are taller and have space at the bottom for accumulating lead sulfate. When the sulfate builds up enough it can literally short between the plates. Lead plates can also fracture if they become over sulfated or eroded or if the battery is dropped or set down hard. When they fracture they drop into the bottom of the case and can short out with the another pos of neg plate.
This is why the industry usually uses 80% of new cranking amp capacity as the cut off for needing new batteries. Boaters with low to minimal current demand often push batteries well beyond their useful life and don't have them capacity tested often enough. Pushing batteries beyond this point can lead to consistently higher failure averages.
The best testing methods these days are either capacitance or pulsed load tests. The two big testers used in the industry are Midtronics (capacitance) and Argus (digital pulsed load). They can tell you exactly how many cranking amps the battery has. If you fall below 80% of the batteries stated or rated CCA or MCA rating the battery shows as failed and should be replaced. Marine batteries should ideally be tested with capacitance or pulsed load testers every 12 months. If you can find a shop that uses a Midtronics or Argus tester bring them there once per year and pay them for their time. It can be well worth it.
Many of these testers can print out test certificates for you to keep on hand to track the performance. You should start with a brand new set, get a baseline, and keep the certificates. If you start with one tester always use that same tester or brand.
Midtronics Test Certificate
Argus test Certificates: Batteries that are sulfated can often be extended for some time via controlled equalization charges. These batteries took two equalization runs, one 8 hours and one for four hours. At only 90% capacity the decision was made to retire them because at 5 years old, and never having been "equalized", they could have still been dangerous especially with all the newly shed sulfate in the bottom of the case.
That said ALL devices inside a battery compartment should be "ignition protected" or non-sparking devices.. This goes for fuses, battery chargers, switches, relays etc. etc. etc..... All battery compartments should be vented whether you have wet, AGM or GEL batteries...