It's not as simple as calories in - calories out, though the principle is the right one. And eating less (and moving more) works for weight loss for everyone who does not have a metabolic disorder or some other medical condition.
But why not as simple? Because there is enough evidence to show that not all calories are created equal. There was a thoroughly reputable study (published either late 90s or early 00s) looking at heart disease, and the role of dietary fat in furring up arteries. They divided a matched cohort of men into two groups, controlled diet to same number of calories (and monitored as well as is ever possible when self-reporting, that they stuck more or less to it) and the difference was the types of fat.
As well as their heart/circulation related findings, they also noticed a difference in weight. Those in the 'healthy fat' group lost weight, those eating the same number of calories in the 'any fat' group styled the same. Remember that this was a study in which every variable was considered, this was nit what they set up the study to investigate, and they were not looking for this effect it just jumped out at them.
So calories might not all be 'equal' in the body (which is, after all a little more complex than the internal combustion engine where the in/out theory works perfectly) and quality of fuel does appear to have a role.
That's not a licence to pig out. But is what lies behind the advice to avoid/reduce certain fats and processed ready meals in general, and is evidence why the Mediterranean diet works for wider health and weight reasons.