Overheated and melted batteries are often a result of running out of water. The charger believes it needs a charge and continues charging and the battery overheats and melts. Batteries which have shorted internally due to plate sulfation or breakage will also melt down.
It can also be a result of the charger not correctly reading that the battery is charged and it continues to charge and boil out the water, then melts the battery.
If it was mine, I'd take good pictures of how each of the wires is connected, maybe make a diagram and/or mark any wire which could be mistaken for another. Take all the batteries out, clean and neutralize the entire compartment. Paint or otherwise protect any area that needs attention. Put new batteries in and check the charging voltage. Then, monitor the charge process and water levels closely for a week or more to determine that the charger is working correctly.
You didn't say how long it had been since maintenance was done or how often you check the water levels so it's purely speculation what happened.