If you ever take physical chemistry you'll learn that cavity formation, starting off as small bubbles, is initially disfavored because the external pressure on the bubble is greater with lower surface area, that is small bubbles tend to collapse than larger ones. So why do cavities form? Bubbles actually form on localized points within the medium, in the case the water, that serve as sites for nucleation (try researching "nucleation" on google). As in the case of boiling stones you'll see that that's where the initial bubble formation occurs. The bubbles start to form at a faster rate, as they can at times fuse together which facilitates bubble formation throughout the medium, since the bubbles are now progressively more stable (less likely to collapse). I'll add this later with the mathematical details.