This is because the consumption of refined sugars is unhealthy and affects your health which leads to things like decreased fat mobilization and metabolism.
So what's actually happening is, despite the calorie intakes being the same, the calorie expenditures have changed.
It is still calories in vs calories out. As to weight loss, the TYPE of calories doesn't matter as long as you are in a deficit.
Professor Haub demonstratred just this, check this out - he lost weight eating only junk food and mostly refined sugars. https://conciergemedicinemd.com/the-twinkie-diet/#:~:text=Professor%20Haub%20ate%20Twinkies%2C%20Little,Doritos%2C%20sugary%20cereals%20and%20Oreos.