As gas is compressed, the spaces between the particles reduces. When a gas is compressed the pressure applied to the gas in the container is increased.
According to Boyle's law, the volume of a fixed mass of a gas varies inversely as the pressure changes if the temperature is constant.
So, as the pressure on the gas increases the volume decreases.
This reduces the spaces between the particles.
Volume is the space occupied by a body within a given space.