The water in a river is not standing still: it flows from high to low.
A river often starts in the mountains and ends in the sea. The river basin of a river can consist of different soils. For example, there are soils of stone that almost no water penetrates, such as in the mountains. Other soils are not so waterproof. For example, sandy bottoms allow a little water to pass through. The water ends up in the small holes (pores) between the grains of sand.
The smaller the pores, the more difficult the river water can sink into the soil. So some water can leak out of a river. But the other way around, water can get back into the river from the bottom.
This happens when the soil is very wet, for example because a lot of precipitation has fallen.