While this is true, there a lot more complications.
You body has its own idea of your weight set-point, and tries to keep your body mass in that range. Any short-term intake / expenditure imbalance will be corrected when sufficient calories are available afterwards.
If you are suffering a longer-term shortfall of calories, your body will "turn down the thermostat" in a couple ways. One by literally producing less heat, but your metabolism slows down in other ways, and an emphasis is put upon storing calories as fat.
So if you cut your calorie consumption, and your body decides to cut calorie expenditure even more, you can gain weight.
Also, your body will reduce muscle mass in a reduced caloric intake situation, because it will burn that muscle mass as energy to power the rest of your body, and also because muscle mass just uses more energy even when it is not doing anything.
Going on a diet that causes you to lose muscle mass is a recipe for rapid weight gain after you stop dieting.
Unfortunately, many fad diets will work in the sort term, but will make it easier to gain weight back later on.