You can stack the batteries in one place, in small compartments. If one compartment catches fire, it's easier to contain than in a big compartment with cars that take up much more space. It could even mean that you ditch the compartment in the ocean, to prevent a bigger problem. But compartments can be designed to be cooled with salt seawater without damaging the ship.