The mass of a gas does change when it is compressed. When a gas is compressed, the molecules are forced closer together, which increases the density of the gas. The density of a gas is defined as its mass per unit volume, so as the density increases, the mass of the gas also increases.