HC thanks, to amplify my comments a bit further:
it's an 'open system'; the difference in total energy between a fluid exiting the system, and the fluid entering the system, is equal to either a) the work done on the fluid (compression powered by the gas generator in this case) resulting in a temperature rise, or b), the 'heat' extracted from the fluid within the system, resulting in a temperature decrease.
(Words in '...' are Thermodynamic terms)
I could say "it's not rocket science", but perhaps in this case that's a bad example!!
Edited to add: Naturally the simplistic equations stated do not take into account losses occuring within the system, e.g. heat transfer to the turbines and casing, but illustrate the basic principle of an open system.