Work done by system of ideal gas in isobaric expansion
At the interface between the gas and its surroundings, by Newton's 3rd law, the pressure exerted by the gas on its surroundings is equal to the pressure exerted by the surroundings on the gas.  So we can use either.  For a reversible expansion, the gas pressure is given by the ideal gas law.  But the ideal gas law only applies at thermodynamic equilibrium and during a reversible process (which consists of a continuous sequence of thermodynamics equilibrium states).  For an irreversible expansion, the ideal gas law doesn't work (i.e., gives the wrong answer), and we can't use it to get the gas pressure at its interface with the surroundings (where the work is being done).  But, if we know the surroundings pressure during the irreversible expansion, we can still calculate the work (because, at the interface between the gas and surroundings), the two will match.  So using the external pressure is always a valid approach to getting the work.