Why do we use external pressure when calculating work done by gas? [duplicate]

This question already has an answer here:

For irreversible expansion and compression, why is dw= -pextdV but not dw= -pdV ?

Many of the texts and related questions on this site I encountered give a same general idea: because work done= opposing force x displacement. Using this reasoning, I cannot explain my following thought processes:

(a) In the case of compression, the opposing force is obviously caused by p but not pext. Based on Atkins' Physical Chemistry Ninth Edition page 50, we use pext even for compression.

(b) The explanation given by Atkins' Physical Chemistry (same page) is:

'when a gas is compressed, the ability of the surroundings to do work is diminished by an amount determined by the weight that is lowered, and it is this energy that is transferred into the system.'

Sounds right. Now if I use this reasoning on expansion,

1. Imagine I have two pistons, two filled with different amount of gases at same volume and so different pressure.
2. Envisage the external pressure being a load resting on the piston.
3. When both gases expand by the same amount, the work done by both gases, based on the formula dw= -pextdV and Atkins' reasoning, are the same. This is because the load moved up by same vertical distance and the changes in volume of gases are the same for two piston.
4. However, logically, that piston with higher pressure should move faster and so does the load on it. This would mean that, that load actually has higher kinetic energy.
5. With both gases doing the same amount of work, two loads gain the same gravitational potential energy, but one of the loads gains greater kinetic energy, means that one of the loads actually gain greater amount of total energy. How is this possible?

(c) We always say when p=pext during expansion, the work done by the system is maximum, otherwise 'work wasted'. How can you say that it is wasted when the work actually used to increase the kinetic energy of the load as a whole?

marked as duplicate by Mithoron, Todd Minehardt, andselisk♦, Karsten Theis, Jon CusterMay 13 at 15:50

At the interface between the gas and its surroundings (say the inside face of a piston) where the gas is doing work, by Newton's 3rd law, the pressure of the gas matches the "external pressure," and, if this external pressure is known, the amount of work that the gas does on its surroundings can still be determined. In the "vertical piston" example, if one does a force balance on the piston during the process, one obtains: $$P_{gas,I}=\frac{Mg}{A}+P_{atm}+\frac{M}{A}\frac{d^2V}{dt^2}=P_{ext}$$ where $$P_{gas,I}$$ is that gas pressure at the interface with the piston (the subscript I is present because, in an irreversible process, the pressure of the gas within the cylinder may not even be uniform), and the mass times acceleration of the piston is included. The work done by the gas on its surroundings during the process is obtained by integrating this equation between the initial and final equilibrium states to yield$$W=\int{P_{gas,I}dV}=Mg\Delta h+P_{atm}\Delta V=\int{P_{ext}dV}$$This equation acknowledges that, as a result of the viscous property of the gas, the kinetic energy of the piston has been damped out by the time the system reaches its final state.