Not in the way you think it is. It's true that if you gain weight then you must have consumed more calories than you burned. It is not true that if you consume more calories than you burn that you will gain weight. This is not a closed system. You could literally poop out the difference.
As far as it goes, it is a useless statement anyway. The point of calories in/calories out rhetoric is not about the physics; it's about how animals regulate their weight. You could make the same case that body temperature is about heat in/heat out but that would be missing the point of how humans regulate body temperature. The criticism of calories in/calories out is in this vein. Do you think you control your body temperature by consciously monitoring heat transfer? Then what makes you thinks complex animals control their body weight and composition by consciously controlling their calorie usage and intake?