They don't really "explode" per se, it's due to a process called thermal expansion. The ink in a pen is liquid in a confined tube, mostly sealed at the "ball-point" end, but open at the other. Increases in temperature from body heat expands the liquid much as mercury rises in a thermometer, until it exits the tube causing a mess.