Let's consider a gas inside a closed cylinder with a piston. This can be considered a closed system. The First Law of Thermodynamics (FLD) for a closed stationary system can be given as
Q = U + W
where,
Q is the heat out of the system
U is the change in internal energy of the system
W is the work done on the system
Now I can compress this gas by doing some work on it. If I compress the gas isothermally, there is no change in the internal energy of the system, and the work done on the system will equal the heat out of the system, i.e., Q = W. In this case, the pressure of the system increases due to compressing the gas isothermally. Question: The energy into the system due to work done on it is equal to the energy out of the system in the form of heat. But the pressure of the system increases, which has the 'capacity to do work'. This increase in pressure seems to store energy, like a compressed spring. Where is this energy, stored as pressure, coming from?
Ref: https://chemistry.stackexchange.com/questions/154236/does-entropy-contribute-work