How are the calorific values of foods determined?
Cecil’s article:
In other words, they just measure how much fat, (digestible) carbohydrates and protein there is, which is probably easier to do than try burning (literally) a sample of food inside a closed container (and more accurate; substances like cellulose will burn but aren’t digestible). The calorie contents of different nutrients may vary slightly; I’d expect saturated fat to have slightly more energy than unsaturated fat because of the extra hydrogen atoms; there are also carbohydrates like sugar alcohols (counted separately) that can have considerably fewer calories.