Simple but correct answer: When a gas is compressed, the molecules are much closer together, increasing the friction between them as they move. That friction creates heat.
The same principle in reverse is used in cooling systems: a compressed gas is allowed to expand, cooling as it does so and thus pulling heat from the air or water as they pass through the coil.