This isn't entirely true. If you take in the same amount of calories but something changes your metabolism, you can switch from using all the calories and entering a deficit, or storing the calories as fat. This is partly what happens with ketosis. You can eat the same amount of calories overall, but with almost no carbohydrates, and this changes your metabolism. You will lose weight in keto without excercising more if you are so inclined. Like many things, it's a good rule of thumb to say that less calories == less weight, but it's a nuanced situation. That's not always true.