What happens depends upon whether the change is done isothermally or adiabatically.
Suppose the gas is ideal then the internal energy $U$ depends only on temperature and is independent of the volume or pressure (by definition) and therefore for an isothermal expansion/compression $dU=0$ and so by the first law $dq=-dw$ where the work is $dw=-pdV$ and for an ideal gas $p=RT/V$. As the internal energy and temperature is unchanged, so is the kinetic energy. In a real gas at low pressure intermolecular interactions can be ignored and this behaves as if an ideal gas. (If this is not the case then $p$ would have to be given by, say, the van-der Waal equation which greatly complicated any calculation, but some work will be needed to compensate for the intermolecular forces).
In the adiabatic case no heat leaves or enters the system (i.e. no heat exchanged with surroundings) and therefore and expansion or compression is done at the expense of the internal energy and the temperature will change. The change in internal energy is given from the first law as $dU=dw$. On compression the temperature rises. If the gas is one of atoms then there is only kinetic energy which increases. In a gas of molecules, kinetic energy also increases but additionally rotational /vibrational energy levels can be populated according to the Boltzmann distribution.
The original experiments by James Joule (1843, in a brewery in Manchester, England) showed that mechanical work results in an increase in temperature; "Wherever mechanical force is expended, an exact equivalent of heat is always obtained."