Why is work done equal to $-pdV$ only applicable for a reversible process?

In a quasistatic process (reversible), the difference between the external pressure and the internal pressure is infinitesimal for each infinitesimal change in the volume of the system.

$P_{ext}=P_{int} \pm dP $,

As you know that the term for work in terms of pressure is given by, $dW=PdV$. This means that work obtained will be maximum if the pressure is maximum for each infinitesimal change in volume.

In a reversible process, the work done in each step obtained is maximum since the external pressure in only infinitesimally greater (or smaller) than the internal pressure.

This enables us to connect the internal pressure and external pressure (since they are almost equal) using the ideal gas law, which in turn enables us to derive work in terms of volume change, without knowing the pressure.

$P_{int}V=nRT$

$W_{int}=\int_{v_1}^{v_2} P_{int}dV$

$W_{int}=nRT\int_{v_1}^{v_2} \frac{dV}{V}$

For non-reversible process, such thing is not possible. This process is instantaneous. Internal pressure won't have enough time to become almost equal to external pressure. Only, external pressure is a way to find the work. The work done by internal pressure and external pressure are equal in magnitude. For some processes, external pressure is given. We can either simply calculate the work done by using external pressure and volume change or use to ideal gas equation to remove the pressure term. But the latter is won't be possible, since you do not know how the internal pressure is changing. In case of reversible processes, you had the ideal gas equation to give you a relation between pressure and volume.

Hence, we use the constant external pressure (when you put a weight on the piston you get constant external pressure) to calculate the work.

Therefore, for non-reversible processes,

$W=P_{ext}(V_f-V_i)$

Moreover, work done by a particular pressure is not $\Delta P dV$. For instance, when there are two forces acting on a body the work done by a particular force is not given by the the work done by the net of the two forces but instead the work done by a particular force is given by that force's magnitude and the displacement of the body in that force's direction.