This is an argument I have with the sciences. An expanding system does work onto the surrounding atmosphere. Consider the expanding system as a subsystem of our atmosphere, hence as it expands it does work onto the surrounding atmosphere i.e. it is as if the atmosphere has expanded, hence the work onto the atmosphere is [(Psys)(dVsys)]. Since the system's final pressure is 1 atm and the volume change is such that (dVsys)=(dVatm), we can write that the work done onto the atmosphere is [(Patm)(dV)atm].
The confusion originates from not writing the enthalpy equation correctly because simply writing H=E+PV does not tell us what is happening where. So clarity is given by writing
dH=(dE)sys + (PdV)atm and since the work is done exterior to the system then we can rewrite it as
But the above can be confusing. Imagine we are heating water bring it to a boil, and dQ is the energy in (due to heating. Now we would write
dQ= (dE)sys + (PdV)atm = (dE)sys + (W)atm
The reason is that the heating must do two things
1) change the system's internal energy
2) do work onto the surrounding atmosphere
The above equation is really latent heat of vaporization with the systems energy change being it changes in the bonding energy i.e. (dE)sys = (dU)sys
Now I argue (this is published in peer review [1,2,3] but remains controversial) that the work done onto the surrounding atmosphere: (W)atm = (PdV)atm is lost work because it is irreversible i.e. in order for the atmosphere to work on a system, then the atmosphere must be at a higher pressure than the system. This is controversial because it can become a challenge to the second law, namely lost work into the atmosphere means that the second law is no longer necessary to explain why we cannot have perpetual motion, or why energy is lost by expanding systems like a steam engine or why the Carnot cycle is ideal rather than realistic.
 Mayhew, K.W. "Second Law and Lost Work" Physics Essays 28,1 (2015) pg 152-56
 Mayhew, K.W. "Resolving Problematic Thermodynamics" Hadronic Journal vol 41 no 3 (2018) pg259