Cavities break through the surface enamel of teeth, and they’ll probably get bigger unless you close them off with fillings.  A combination of strong materials or a white mix called a composite goes into the cavity soft and then hardens as it dries.