Formation of stalactite and stalagmite is the property of calcium bicarbonates which changes to carbonates.
Limestone caves, where most stalactites and stalagmites are found, are mainly composed of calcite, a common mineral found in sedimentary rocks. Calcite molecules are made of calcium and carbonate ions, and are referred to as CaCO3, or calcium carbonate. When rainwater falls over a cave and trickles through rocks, it picks up carbon dioxide and minerals from limestone. If we add water, carbon dioxide and calcium carbonate together, we get this equation:
H20+CO2+CaCO3⟶Ca(HCO3)2
Ca(HCO3)2 is known as calcium bicarbonate, and the water carries the substance, basically dissolved calcite, through the cracks of the roof of a cave. Once water comes into contact with the air inside the cave, however, some of the calcium bicarbonate is transformed back into calcium carbonate, and calcite starts to form around the crack.