You’re absolutely right that in an “ideal fluid” theoretically you could compress and expand the gas and it would return to its original temperature. In real life, the process of compressing the air is not 100% efficient (entropy; due in part to friction) and so you will introduce heat to the air. This means you end up with a higher temperature even after expansion to the original pressure.
In flight your objective is to compress the low density ambient air but there is no need to expand it. Therefore your air temperature will be higher primarily because of compression and secondarily because of entropy. This is not such a bad thing because the ambient air you start with can be pretty chilly!
Not sure what your background is so apologies if I’m teaching you to suck eggs.