Batteries will spill acid all over in an accident
Lead-acid batteries are constructed from a lot of separate cells. One cell generates 2 volts, so a 6-volt golf-cart battery has 3 cells, and each of them contains some sulfuric acid. Quite likely, if such a battery is impacted hard on an end or a corner, only one cell will be breached. The most that you would expect is that some of the cells in some of the batteries will be breached in a really bad accident, and perhaps a gallon or so of acid could get spilled on the ground.
But acid is not flammable. And while it is spilling on the ground, you do not need to touch it; you'll probably still be inside the car, if you were wearing your seat belt, or thrown out away from the car if not. Hopefully the battery compartment in your car is sealed from the passenger compartment. If a hazmat team comes to clean up the spill after your accident, they will probably just sprinkle baking soda on it and then wash it away.
A full tank of gas, on the other hand, can quite literally become a bomb. We've all seen plenty of this in the movies, and they are only slightly exaggerating the effects of having hundreds of miles' worth of fuel be burned all at once.
If you are designing and building your own car, a strong battery box is an important safety feature. Usually they are built from welded angle iron, and it is very good if you can have each battery supported by angle iron on both sides. There must be hold-down straps or brackets which are sufficient to restrain the batteries from flying out, in any accident imaginable. Quite likely you will need to fully enclose the battery box, to keep them warmer in the winter, and keep them clean and dry all year, and for this some relatively flimsy sheet material (plastic or metal or wood) can be used, but the structural stability is the most important part. The batteries should be supported by a welded frame which is welded in place and has become part of the frame of the car.