While this is broadly true, I think it's also important to convey that the hormones involved also play a huge role. There are plenty of people who stay in a calorie deficit* and still gain weight because they spike insulin with a snack or a meal every two hours.
Keto works so well because it doesn't spike insulin as much, on top of the greater satiety signals sent by popular foods associated with the diet. Eventually you feel more full for longer and the insulin spike is further reduced from the omission of calories entirely.
*: By constantly spiking insulin, the body will down regulate your metabolism since it can no longer access stored fat deposits for energy. If your BMR is lowered, then technically you are burning less calories than you are eating. Assuming a person stops spiking their insulin, their BMR will rise back to "normal" levels when the body realizes that it has access to stored fat again.