When the water containing dissolved calcite gradually drips from the ceiling of the caves, water evaporates and the remaining calcite hangs from the ceiling and thus Stalactites are formed.
When the calcite deposits rises upward like a pillar Stalagmites are formed.