When the rock is limestone or dolomite caves can form. The water reacts chemically with limestone and slowly a larger and larger space will form. This is what you call chemical erosion. As the space becomes larger and larger the water can flow through. As it flows it erodes .
Physical erosion washes away rock and sand.
This is what makes a cave larger and forms an underground stream. Finally over hundreds of thousands of years or even millions of years the cave is formed. Here is an activity that you can try. The reaction of the two substances illustrates the process carbonic acid dissolving limestone, but actual limestone solution by carbonic acid is a weaker, less noticeable reaction.