The pressure of a gas depends on the amount of times per second that the molecules strike the surface of the container. If we compress the gas to a smaller volume, the same number of molecules are now acting against a smaller surface area, so the number striking per unit of area, and thus the pressure, is now greater.