Each dam is constructed to withstand a certain amount of water.
If you notice any dam you will see that the bottom of the dam (the base) is thicker and as we climb up it is thinner.
This is because the pressure of the water
is higher as we go deeper.
In case of heavy rainfall the water of the dam may exceed a critical number.
This increases the pressure on the lower level of the dam which in turn may cause damages or even the collapse of the dam.
For this reason the overflow pipes exist.
The pipes open and let an amount of water to go.
The overflow pipe is the black rectangle that appears on top of the dam in the photo.
In normal operating conditions the water leaves from the bottom of the dam towards the turbines.