Calories consumed minus calories burned: it’s the simple formula for weight loss or gain. But dieters often find that it doesn’t work.