Here's something to think about:

When someone says that it's just "calories in/calories out," they are 100% right. But I'm going to give you an example, that I think will make you realize, that while true, that law is actually irrelevant to weight loss, and that all calories are not equivalent.

Let's say I gave you a pill to eat every morning. This pill contained only four calories. However, this pill affects your hormonal balance, and it makes you ravenously hungry all the time, and also quite lethargic. Perhaps it's related to your thyroid, but that doesn't matter for this example. What matters is that it makes you hungry and sedentary.

As a result, you are going to gain weight. The pill is only a few calories, but you will gain weight because it has made you to eat a lot more food and move around less.

Has your "calories in/calories out" thermodynamic law been violated? No, because, as a result of your extra eating, you have taken in a lot more calories, and expended fewer. But because of the nature of these calories that you've eaten, namely those four calories in the pill that affect your metabolism, you have gained weight. If you were to stop taking that four-calorie pill, you'd lose weight.

In other words, calories in/calories out is true, but not helpful in understanding weight gain or loss.

If you lived in a cage, and had no control over what you eat, then calories in/calories out would be relevant. In the real world, it is not.

By the way, in a similar way, eating lots of carbohydrates can force your body to store energy in fat cells, which in turn forces you to eat more and expend less, kind of like my hypothetical pill.