Thermodynamic laws certainly apply, but you just can't measure all the variables properly. Trying to apply that kind of input/output calculations on such a complicated bio-chemical model like human body is just a naive over-simplification. First you would need to calculate the caloric value of your complete excrements (including sweat), before you even know what the actual energy input is. Than you would need to measure precise oxygen used by body and the heat produced to be able to know how much of it is used by body. Not to mention that you even don't know the exact caloric values of the food that you eat. Guesstimates of this whole process that we have in a form of calorie tables and calculators are only a rough guidelines, not exact science, and that's why in real-life numbers never add up. Not because human body somehow breaks the laws of physics, but because popular calculations completely ignore a lot of biochemical nuances. How efficient is your guts in digesting different types of food, which pathway is used to turn that food into the energy and how efficiently due to levels of specific enzymes, does your body (due to the current hormonal levels) prefer to store the calories or to burn them, how efficiently you muscles are using that energy (depending on you height, weight, age, sex, health), and many, many other little details that all count.