Pretty simple fact, you shovel more calories in your pie hole than your body can burn, you will gain weight.
If you don't shovel more calories in your pie hole than your body can burn, you will lose weight.
It also depends on what kind of calories. Sugar and things that quickly turn to sugar are especially bad. If your body can't burn it fast enough, it will store it as fat. That's also why it's better to eat smaller meals.