Here's a little geology lesson. The caves were formed by water seeping into fissures in the limestone. The water mixes with carbon dioxide in the air and soil and forms carbonic acid, which adds a chemical process that interacts with a mineral in the limestone, which dissolves in the water. The dissolving mineral (calcium bicarbonate) drips away with the water and leaves a cavity -- the cave -- where the limestone rock used to be before part of it dissolved away.
I should repeat a disclaimer I made during one of my earlier posts about plants. My scientific training is limited to one college class: Introduction to Biology for Non-Science Majors. The above explanation is from a Costa Rica National Parks Guide book that I have, not based on any personal expertise.