In a gas, molecules are far apart
This makes the gas easy to expand and compress
When a gas is compressed, the volume is decreased
The density of the gas increases, since the size of the container has decreased but the number of molecules has remained the same
This allows more frequent collisions of the molecules on the container wall
This means they hit the walls with a greater force and therefore increases the pressure
When a gas expands, the volume is increased
This causes a decrease in pressure