The following derivations assume laminar flow, meaning the fluids flow smoothly without turbulence or transverse motion. For the topics covered here, this condition is generally well met under normal circumstances.
If a fluid such as water flows through a pipe with cross-sectional area $A$, the volume flow is defined as the ratio of the flowed volume to the elapsed time, or more generally as the differential quotient:
$$
\boxed{Q = \frac{\mathrm d V}{\mathrm d t}}
$$
If we substitute $V = As$, where $s$ is the distance traveled and $A$ the cross-section, we obtain the relation:
$$
Q = Av
$$
Here, $A$ is the cross-sectional area of the pipe through which the fluid flows, and $v$ is the velocity of all fluid particles. Liquids are typically incompressible to a good approximation, meaning their volume cannot be significantly changed by external pressure. Therefore, the volume flow must remain constant throughout the entire pipe.
In a pipe system with varying cross-sections, the constancy of the volume flow (as illustrated conceptually) leads to:
$$
\boxed{\frac{v_1}{v_2} = \frac{A_2}{A_1}}
$$
The ratio of the velocities is thus inversely proportional to the ratio of the cross-sectional areas. In other words: the narrower the pipe, the faster the liquid must flow to ensure the same volume per unit time.
For cylindrical pipes, using the formula for the area of a circle, we get:
$$
\frac{v_1}{v_2} = \frac{r_2^2}{r_1^2}
$$
Here, the factors of $\pi$ cancel out in the numerator and denominator.