To introduce those who may be unfamiliar, 'energy in' refers to the calories or energy that we consume via macronutrients provided in the diet (carbohydrates, fats, protein and alcohol), and 'energy out' refers to the energy we use for basic metabolic requirements to maintain our normal bodily functions, the thermic effect of food (energy required to absorb and digest nutrients), and of course physical activity/exercise!
The basic principle: Energy in = Energy out = Weight maintenance aka ENERGY BALANCE
Energy in>Energy out = Weight GAIN
Energy in<Energy out = Weight LOSS
So yes, it really is that simple! Energy balance is the #1 undisputed body weight regulator in 40+ years of research. If you want to lose weight, you need to have a calorie deficit (expend more energy than what you eat). Same for weight gain, you will need to consume a calorie surplus in order to expend less energy than what you're consuming.
This is why every weight-loss diet works; whether it be low fat or low carbohydrate & high fat- whatever suits the individual's preference. However the common issue here is that these 'diets' that are restrictive with or exclude whole food groups may become difficult to maintain, and can often lack in certain micronutrients.
With special consideration to one's individual requirements, preferences or any allergies present, I would recommend eating a balanced diet that is inclusive of all food groups, high in un-processed, fresh and colourful foods to suit your energy requirement.