It has always been black and white that the number of calories consumed relates directly to weight gain or loss.
Everything else is about tangentially-related issues. Eating 'better' food (and there are many definitions of 'better') may be healthier. Eating unprocessed food may be healthier, and/or digest more slowly, and/or reduce hunger. Eating different food groups in different balances (e.g. high protein, whatever) may affect how quickly you become hungry, or support certain exercise better. Low/no-carb/keto diets may help some people lose weight more quickly/easily, and probably results in a steadier blood sugar profile. Limiting eating to certain time windows and/or fasting may have some health benefits, and also contribute to weight loss. (And some types of regimen may suit some personalities better.) Eating certain types of food (fat, protein, low-GI carbs) which are also not processed may digest more slowly, resulting in a steadier blood sugar profile and less hunger. Etc.
And despite all of this, it's also possible to lose weight by eating the worst food in the right quantities. See [0] or just Google the "Twinkie diet".
[0] https://www.huffpost.com/entry/chewing-on-the-twinkie-di_b_7...