Lithium batteries are made to deliver high output with minimal weight. Battery components are designed to be lightweight, which translates into thin partitions between cells and a thin outer covering. The partitions or coating are fairly fragile, so need to be handled with care and cannot be punctured. If the battery is damaged, a short circuit occurs. This spark can ignite the highly reactive lithium.
Another possibility is that the battery can heat to the point of thermal runaway. Here, the heat of the contents exerts pressure on the battery, potentially producing an explosion. This is mainly caused during charging and discharging of battery.