I'm no chemist or physicist but I know the answer.
The real answer is that CO2 can be stored under pressure in liquid form. When you release the pressure, it morphs into gas form and in the process absorbs a lot of heat, that's why the cartridges are so cold after you use one. If you just tried to compress enough air to inflate your tire it would take a lot bigger and stronger cartridge.