Is the weight loss just from sleeping better and therefore making better food choices?
Almost certainly plays a role. Also increased activity levels due to better less fatigue.
Certainly is not defeating thermodynamics, assuming calorie absorption is not disrupted somehow it's likely the above.
Underrated question
Personally, when I have not slept well and need to be productive in a day, I’m much more likely to want to load up on sugar and unhealthy food