To understand this in more detail, consider a cylinder with a piston that is used to compress air. As the piston moves down, the volume of the cylinder decreases and the air molecules are squeezed closer together. This increases the frequency of collisions between the molecules, which causes them to transfer more energy to each other. The increased energy causes the molecules to move faster, which increases their speed.
The amount that the speed of the molecules increases depends on how much the air is compressed. The more the air is compressed, the greater the increase in speed. This is because the molecules are squeezed closer together and the collisions between them become more frequent.