Lithium batteries contain toxic chemicals, as well as the metal Lithium, which can catch fire at room temperature, so they are enclosed in a strong, sealed but flexible wrapper. If the chemical reaction in the battery outgases it inflates the wrapper, causing the battery to expand but still containing the reaction. This is an intention design feature to prevent fires and chemical spills. If it happens to any device with a rechargeable battery you should immediately take it to an Apple store, or click Get Support at the top of this page to discuss repair options. It is safe as long as the wrapper is not punctured, so be careful with it. As to why it happens, it’s just a random failure mode that happens to a small number of batteries. As to how often, well, it’s happened to my 2013 MacBook Pro twice now.