Keto is a very special case where the body depletes its glucose storages so it switches to fat by force. It does work, but you have to stay out of any kind of carbohydrate for the rest of your life (or for whatever amount do you plan to stay in that state).
In non ketogenic states, input does somewhat equals output.
Nutrition experts still try to create a caloric deficit when they create nutrition plans.
If there was some sort of magic nutrient that made you lose weight by eating mostly the same food, I'm sure most nutrition experts would have known already.