It is, of course, not as easy as calories in / calories out, although the "Twinkies experiment" proved that you can in fact lose weight via caloric restriction alone. For any kind of "normal" diet insulin plays a massive role in obesity. And that bag of candy will absolutely send it to the stratosphere, especially if you consume sweets frequently. Buy a continuous glucose monitor (it's now available OTC via Stelo), and see for yourself. That's what I did.
I am aware of this, I am more trying to get those that really believe it is as simple as calories in calories out to break free from that Plato-ey over-simplified explanation.