According to formula work done is (Resisting pressure X dV)? Then in case of compression, isn't the resisting force is internal Pressure? Then why we the formula for compression is same as expansion which is (External Pressure X dV)?
By Newton's 3rd law, the internal force exerted by the gas on the inside face of the piston is equal to the external force exerted by the inside face of the piston on the gas. If the expansion or compression is reversible, the internal force can also be determined by the ideal gas law, which applies at essentially thermodynamic equilibrium. But, if the expansion or compression is irreversible, the internal force cannot be determined using the ideal gas law. So the only alternative is to use the force manually applied externally (if this is known).