Lithium-ion batteries have a high energy density. They store a lot of energy in a small body full of flammable components. When a cell is damaged, it leads to a sudden rise in pressure and temperature that releases flammable gases.
It begins a chain reaction that instantly takes out all the other cells in the battery pack too. The combined release of energy produces a violent explosion or an aggressive fire to break out that causes a lot of damage.