This water now holds the dissolved rock is exposed to the air in the cave, it releases the carbon dioxide gas, like a bottle of soda being opened. As carbon dioxide is being released, calcite is precipitated on the cave walls, ceilings, and floors. As the precipitated minerals build up after many thousands of water droplets a stalactite is formed. The water droplets that fall onto the floor can form a stalagmite if the droplets still have some dissolved calcite in them. The color of speleothems are resolved by the mineral content.
Pure calcite is white and almost colorless.
Iron and other minerals combine with calcite crystals to add shades of red, orange, and black to the color of speleothems.