According to a book I am reading, diet science currently agrees that there is one way to loose weight: A calorie deficit.
Not actually true, broadly true, but not actually true.
For example, if I need 2000 kcal a day and eat only 1500 kcal a day, I will loose some weight over the next weeks/months.
I strongly recommend not doing a blind calorie deficit for body composition purposes. This non-fasting deficiency will reduce your resulting metabolic rate.
Calories are basically measured by burning food and measuring how much energy was set free.
Calories are measured by exploding items in a bomb Calorimeter and measuring the photons produced. This is a mechanical apparatus that tells us about combustion, but is not the human digestion system (there are real differences). For instance wood has amazing calorie density but doesn't do much for you as a human if you eat it.
My question is: Why and how does it work so good and why are calories interchangeable?
It broadly works in that if your burning X calories per day but only supplying X-500 calories the deficiency will need to be mobilized from your stored fat (ideally), but the body can also solve this little math equation by reducing your metabolic rate reducing the burn, it certainly will increase your hunger and cravings.
Calories are 100% NOT interchangeable.
They key is that thermodynamics applies to closed systems without mass transfers. Humans are open systems that do mass transfers all the time pooping, eating, drinking, peeing, breathing (carbon, oxygen, water vapor), and while humans don't violate the laws of thermodynamics it is nearly impossible to isolate the system to meaningfully
The far more clinically relevant viewpoint is the [Paper] The Carbohydrate-Insulin Model of Obesity - Beyond “Calories In, Calories Out” - 2018
Fat burning, requires the absence of insulin in the blood. People using CICO for weight control are entering a low insulin state between meals, when they sleep, etc. Any time carbohydrates are consumed, blood glucose rises, raising insulin - when insulin is elevated the body will not mobilize fat from adipose tissue, i.e. it pauses fat burning. So someone eating the standard 3 meals and 3 snacks with carbs is pausing their fat burning 6 times per day (for 2-4 hours per eating session depending on their inherit insulin resistance) - Which is almost the entire day.
This means a calorie from carbohydrates pauses fat burning for 2-4 hours, but a calorie from fat or protein does not. A calorie is not a calorie.
Why is there no difference (concerning weight loss), if I eat 1500 calories as pure sugar or eat them as pure protein (where I would assume the body needs more energy to break down the protein)?
There is a huge difference, as detailed above, the 1500 calories of sugar pauses the fat burning, the 1500 calories of protein does not. At the end of a day of eating sugar you will have less time actually burning stored fat.
The downvotes I get when I talk about the limitations of the CICO rule of thumb show how appealing it is to people, but the reality of the human system is rooted in hormones and they can't be ignored.
It is possible to burn fat while consuming more then 1500 calories per day, body recomposition is documented in case studies of hyper caloric diets.. this only works because of the insulin hormonal model.