Let us consider a system of gas in a container with a massless , frictionless and movable piston which is in equilibrium with the surrounding.
Now , From first law of thermodynamics , we know that
$dQ = dU + dW$.
$Q$ here indicates the energy flow due to temperature difference between the system and the surrounding.
But since you assumed $Q$ to be zero this means that the system is in thermal equilibrium with the surrounding.
Now if you want to do some work with minimal loss of energy due to friction, then we proceed with a quasi static process or say a reversible process in which the system is in equilibrium with the surrounding all the time.
Now initially the system was in equilibrium , so
$P_{ext} = P_{gas} = P$
Now if you bring an infinitesimal change in the external pressure , say $dP$, i.e the external pressure becomes $P+dP$ then the volume of the gas changes by an amount of $dV$. But since it was an infinitesimal change , the gaseous pressure quickly equalises the external pressure.
So, work done by you is
$dW = (P+dP) . dV = P.dV + dP.dV$
The term $dP.dV$ is a very... small number and so we generally ignore it.
The main thing to note here is that the energy which you gave was because of the external pressure $(P + dP)$ and not $dP$. So you must include $(P + dP)$ term in the equation for work and not $dP$ only.
One more thing to note here is that the energy given will change the internal energy and thus the temperature will change but assuming isothermal process this exact amount of energy is released and the system is again in thermal equilibrium with the surrounding.
Since the system is again in equilibrium , the internal pressure equals the external pressure i.e.
$P_{gas} = P_{ext} + dP = P + dP$
Now if you decrease the external pressure by an amount of $dP$ , the gas will again reach its initial condition by doing work on the surrounding and thus it is reversed.
So, you can say that the work done on the system is given by
$W_{ext} = \int (P + dP) × dV = \int P.dV$
Isn't that work done (causing internal energy change) due to change in pressure
Yes it is . But that work was done by the external pressure and not by that changed amount alone. And since you are calculating the work done on the gas you should include the external pressure only and not the internal .
Hope it helps 🙂.