Its basically the Bernoulli's equation. Its because pressure is force over area and the mass of the body of water above it is area times height time density so the area cancels out. You can add velocity into the equation and its a conservation of energy equation. Similarly there is a continuity equation which is a conservation of mass. These two are the backbone of a beginning fluid mechanics course in engineering.