When a river is near its source, it often develops a V-shaped valley as the river erodes down (this is called vertical erosion). At the same time, weathering breaks up material on the valley slopes. Weathered material from the valley sides gets deposited in the river. This material is carried by the river and erodes the riverbed through abrasion.
Waterfalls often form in the upper stages of a river where it flows over different bands of rock. It erodes soft rock more quickly than hard rock and this may lead to the creation of a waterfall.
Formation of a waterfall: