Let us the consider a gas as our system enclosed in a cylinder with piston.
1st case(Expansion of gas):
Here force on the piston is exerted by the gas in upward direction and during expansion piston moves up. So, the work done here is positive(force and displacement in same direction). Also the relation W=PΔV (with their usual meanings) also satisfies the "positive" sense of work, since the volume increases during expansion.
2nd case(Compression of gas):
Here, the surrounding exerts the force on the piston and compresses the gas. Since, the direction of force by surrounding on the system and displacement of piston(both downwards) are in same direction, should not the work done by the surrounding on the system should be positive? But, W=PΔV gives -ve work, since volume decreases during compression. Why does the mechanical concept of work and W=PΔV does not give same result?
1st picture is screenshot of book University Physics. 2nd picture is from here.