Just because we have an imaginary boundary across the entrance or the exit of a control volume (that we draw with a dashed line in a figure) does not mean that no work can be occurring across the boundary. The material on both sides of the boundary communicate with one another in terms of pressure, and the actual material is moving, so that there are displacements taking place. This is much different than the case of a rigid boundary, where no work can occur.
Suppose that, at time t, we were to supplement the material in the control volume by the tiny amount of mass that is about to enter between times t and $t+\Delta t$. (In this way, we can be working with a closed system, like in the usual treatment of the first law of thermodynamics). The mass of this material would be $\rho v A \Delta t=\dot{m}\Delta t$ and the work to push it in would be $pvA\Delta t$, where p is the pressure at the entrance. Combining these two results to eliminate vA, we would have $$dW_{in}=\left[\dot{m}\frac{p}{\rho}\right]_{in}\Delta t$$ By time $t + \Delta t$, a corresponding supplemental amount of mass will have come out of the control volume, and the work to push this mass out would be
$$dW_{out}=\left[\dot{m}\frac{p}{\rho}\right]_{out}\Delta t$$So the net amount of work done by the total material in the supplemented control volume (i.e., our closed system) on its surroundings during the time interval would be $$dW_{net}=\left(\left[\dot{m}\frac{p}{\rho}\right]_{in}-\left[\dot{m}\frac{p}{\rho}\right]_{out}\right)\Delta t$$If we now let the supplemental amount of material approach zero by taking the limit as the time interval becomes very small, we obtain the net rate at which the material in the control volume is doing work on its surroundings at the inlet and outlet:
$$\frac{dW}{dt}=\left[\dot{m}\frac{p}{\rho}\right]_{in}-\left[\dot{m}\frac{p}{\rho}\right]_{out}$$The represents the work to push material out of the control volume against the "piston" formed by the material ahead of it minus the work to push material into the control volume by the "piston" formed by the material behind it.