As water flows underground it dissolves the limestone around it.
The dissolved limestone (calcium carbonate) is carried away by the water in solution.
The video below talks about the formation of caves.
Stalactites, stalagmites and pillars
Water drips from the roofs of caverns very slowly and evaporates. As the water evaporates, through a process known as gas diffusion, solid calcium carbonate is deposited on the cavern roof.
This will build-up over time to form long, thin deposits which grow downwards and look like icicles hanging from the ceiling of a cavern - these are called stalactites.
Some drops of water fall to the floor of the cavern where they splash and evaporate.
The splash spreads the deposit of calcium carbonate and as more and more calcium carbonate
builds up on the floor, short, wide, dumpy features grow upwards from the ground - these are
Occasionally stalagmites and stalactites grow towards one another and join to form a rock pillar.