The mass flow is always the same (when you have incompressible fluid. For low speeds, they all are).
So when the cross section changes, the speed changes too. And
Qm=ρ⋅A⋅V=const
In the smaller cross section, you have more speed, and so you have more kinetic energy.
But potential energy...