Rivers run underground for the same reasons, and as a result of the same causes, as rivers on the surface.
Earth’s crust soaks up precipitation until it can hold no more. Some areas of the crust are so absorbent that water gathers deep underground.
If the crust’s material is more easily eroded underground, the water will begin to flow under the surface. It may emerge onto the surface at a later point in its course if the terrain changes. In the same way, a surface river can disappear underground if the rock material is more easily eroded there.
Similarly, underground lakes have the same characteristics as surface lakes. Whether water gathers above ground or underground depends on the ability of the surrounding environment to absorb water.
Precipitation falling on saturated ground might erode the softer earth underground until it reaches a resilient layer instead of pooling on the surface.