With a healthy diet and a reasonable amount of exercise, it's actually difficult to gain weight. You won't get food cravings, your body may occasionally be in ketosis, etc.
OF course, but you are still ignoring the driving factor- a caloric deficit. If you go over your caloric deficit with "healthy" high calorie foods like avos, almonds, olive oil etc you will still gain weight just like you would with processed foods. There is no getting around thermodynamics, although I do agree that choosing whole foods, especially high quality proteins and veggies, is a good way to indirectly reduce caloric intake.
Also, keto is BS as a weight loss strategy and was debunked years ago. When in excess, people on keto still gain weight. Their bodies simply become more adept at converting fat into energy, however you are also consuming more dietary fat so it only pulls from body fat stores when in excess.
Lemme guess . . . . You're a Gary Taubes fan
With a crappy diet and lot's of exercise, it's difficult to not gain weight. More of your calories will be converted into fat, you'll have food cravings, energy swings, and generally feel like sh!t so will probably be less active.
Sure, I'm not disagreeing with that. You do understand the difference between DIRECT and INDIRECT effects, don't you?
The links I posted above show that you can still lose weight with a crappy diet as long as calories are in check.