A cave, or cavern, is a hollow passage underground, usually with an opening to the surface. They are found on planets throughout the Milky Way Galaxy.
Troglodyte was a term meaning cave-dweller.
Caves could be natural or artificial. Natural caves could be formed by water or lava flows. Ice caves also existed. (TNG: "Final Mission"; ENT: "Dawn", "The Aenar")
Caves could make excellent hiding locations, as the rocks and ores in the walls could stop sensors from penetrating them. They also made excellent shelters from the outside environments. For example, Data, Riker, and Doctor Crusher led the colonists on Melona IV to shelter in caves to escape the destruction of the Crystalline Entity. (VOY: "Parturition", "Friendship One"; TNG: "Angel One", "Silicon Avatar")
They were also useful hiding places. After the Vaadwaur homeworld was bombarded from orbit in the 15th century, one battalion managed to survive in an underground cavern. (VOY: "Dragon's Teeth") The unification movement on Romulus made use of a cave as a base of operation. TNG: "Unification II") In 2371, a cave system on Avery III hid a Vidiian base. (VOY: "Faces")
Native Americans often used caves as shelters during their vision quests. (VOY: "The Fight")
On Sigma Draconis VI, caves lead into an underground complex established before the decline of its civilization. (TOS: "Spock's Brain")
The Shore Leave Planet, while artificial, featured caves. (TAS: "Once Upon a Planet")
While Spock and Leonard McCoy were trapped in a Sarpeidon ice age, they took shelter in a cave. (TOS: "All Our Yesterdays")
After an asteroid hit Terra Nova in the 2080s, survivors fled to the planet's caves and eventually adapted to underground existence. (ENT: "Terra Nova")
While exploring Archer IV in 2151, a cavern was found. This turned out to be fortunate, as a storm stranded several Enterprise NX-01 crew members who then sought shelter there. (ENT: "Strange New World")
Xantoras featured a cave system stretching over at least fifty kilometers. At the time of the 2153 regime change, a Denobulan Science Academy team was studying the caves. (ENT: "The Breach")
While on Capella IV in 2267, Enterprise crewmembers took shelter in a cave. (TOS: "Friday's Child")
After being attacked by a mugato on Neural in 2268, James T. Kirk was treated in a cave. (TOS: "A Private Little War")
There was a cave near the Starnes Exploration Party on Triacus, which gave off strange tricorder readings implied to be associated with Gorgan. (TOS: "And the Children Shall Lead")
In 2285, it was revealed that the Starfleet Corps of Engineers had spent ten months excavating a massive cave system on Regula, while a matrix to terraform the caves needed only a day. (Star Trek II: The Wrath of Khan)
In 2351, a ten-year-old Julian Bashir and his father Richard were trapped in a cave on Invernia II by a storm. (DS9: "Melora")
In 2367, Jean-Luc Picard, Wesley Crusher, and Dirgo crash landed on Lambda Paz and ultimately sought shelter in a cave. (TNG: "Final Mission")
In 2368, after being stranded on Galorndon Core, Geordi La Forge and Bochra were forced to shelter in a cave.
In 2373, a group of Maquis refugees had moved to Marva IV, where they lived in caves. (DS9: "For the Uniform")
In 2373, the crew of the USS Voyager encountered a large cave-dwelling creature that ate humanoids, the Hanonian land eel. (VOY: "Basics, Part II")
Caves of note