Thanks to the tireless work of a collaboration between three universities in Spain and France, we now know that the phenomenon occurs because tapping a bottle sends compression and expansion waves through the liquid. This creates bubbles, but also collapses them quickly. When the larger "mother bubbles" collapse, they create smaller "daughter bubbles" in litter sizes that would put both rabbits and Catholics and Catholic rabbits to shame.
As these daughter bubbles of carbonic gas multiply, they change the pressure inside the bottle and give the original beer foam an extra bit of buoyancy that leads to a mushroom cloud-like explosion inside the beer bottle. Neither mother nor daughter bubbles want to be anywhere near that explosion, so they rise to the neck of the bottle and cause the foam to spill out of the bottle, thus greatly lowering the beer holder's immediate chances of creating any daughters of his own.