Why do we use the external pressure to calculate the work done by gas
If the piston is frictonless and massless, then, if you do a force balance on the piston, you must have that the force per unit area that the gas exerts on the inside face of the piston will always be equal to the external force per unit area that one imposes on the outside face of the piston.  The sudden drop in pressure on the outside face of the piston causes the gas to undergo an irreversible expansion.  During an irreversible expansion, the local pressure within the cylinder becomes non-uniform, so that the average pressure of the gas differs from the force per unit area at the piston face.  As a result, the ideal gas law (or other equation of state) cannot be applied globally to the gas in the cylinder.  In addition, during an irreversible expansion, there are viscous stresses present in the gas that allow the force per unit area at the piston face to drop to the new lower value while requiring that force to match the external force on the outer face.  So the work done by the gas on the piston is equal to the external force per unit area times the change in volume:  $$W = \int{P_{ext}dV}$$  This equation is always satisfied, irrespective of whether the expansion is reversible or irreversible.