Counting calories is really just another way of describing the thermodynamics of the conversion of food into energy. This is exactly what we did with fuels and combustion. As a matter of fact, the overall reactions in your body "burning food" match almost identically with the reactions in a fire where you are burning fuel - be it wood, propane, or even octane. Your body does an incredible job of oxidizing food down to its more oxidized forms which are CO2 and water. So go review the burning of fuels in Chapter 5 if you need a refresher on combustion and thermochemistry.
The same principles are at play when your body breaks down food as when a fire breaks down fuels. C-H, C-C, and C-O bonds are all converted into H-O and C=O bonds. The trade off is everything ends up in a much lower energy state - specifically CO2 and H2O. The bottomline is that each macronutrient food type "burns" to give consistant amounts of energy per gram of food. Here is the quick and dirty breakdown.
Carbohydrates - because they all have the same sets of bonds, they all break down to give about 16 kJ/g which coverts to 3.8 kcal/g of carbohydrate. It doesn't matter if the carbohydrate is a simple sugar (glucose), a disaccharide (sucrose), or a polysaccharide (starch). Everything comes out to approximately 3.8 kcal/g. And, since we are generalizing across a multitude of different carbohydrates, we just call it 4 kcal/g. Also note that fiber, or dietary fiber is technically cellulose which means no metabolism and no calories. Fiber is not in our diet for metabolism - it is there for other healthy reasons like better digestion and blood cholesterol manangement.
Proteins - although proteins can and will be primarily used as a supply of amino acids, the break down is exothermic and produces about the same energy per gram as carbohydrates, 4 kcal/g. So pretty easy, both proteins and carbohydrates match with 4 kcal/g.
Fats - of course fats are the most like actual fossil fuels with their long hydrocarbon chains only having C-C, and C-H bonds allows for an even bigger energy drop when changing over to carbon dioxide and water. A gram of fat will burn to release 36.8 kJ/g which is the same as 8.8 kcal/g. Once again, we have a plethora of fats to chose from and therefore we just pick the nicer integer version of that at 9 kcal/g. This is more than double the amount of calories that carbohydrates and proteins give. Fats are truly our jet fuel so to speak and we get more bang (calories) for our buck (the gram).
alcohol - as a point of reference, I'm including alcohol. Let's hope you aren't getting that many calories from alcohol, but let's face it, sometimes we have a drink and maybe another. The alcohol in the drink (ethanol) is actually more energy efficient that carbohydrates, but a bit less than fats. Alcohol comes in at 7 kcal/g. So when you do that shot of tequila - it's not calorie-free, on the contrary, that little 1.5 oz shot of bliss just cost you about 100 kcal.
Soluble Fiber - this special type of fiber does ultimately provide about 2 kcal/g. So if you see some soluble fiber listed on the nutrition label, you will get a little energy off of it. But as a reminder here, insoluble fiber provides zero calories. Only soluble fiber gives you the 2.
or, when is a Calorie not really a calorie?
So you're thinking or asking "why are you putting kcal/g and not just cal/g?" Here is the deal. Back in thermodynamics (and even radiation) we established that the SI unit of energy is the joule (J). It is our "go to" currency for energy. The calorie is really and old and deprecated term - it is not supposed to be used in scientific papers and the like. Use the joule or if you need bigger or smaller, use a metric prefix like kilojoule (kJ). Our food energy count is rather old and archaic - but it IS what people still use and we have to accept it (for now anyway). The problem is that the general public was NOT going to embrace a kilo-anything, and certainly not a kilocalorie (kcal). So somebody somewhere just decided to just use "calorie" as though it is a kilocalorie. In the world of food and nutrition "everybody knows what you mean". The numbers and words are so much nicer. Instead of drinking a 586000 joule 12 oz Coca-Cola or even a 140000 calorie Coca-Cola, you are drinking a 140 calorie coke. Much more human friendly. Then, to help with the confusion of having some calories being "real" calories (like in everything not food related) and others being "food" calories - someone thought, let's capitalize calorie to Calorie. So a food calorie is really a Calorie and is exactly the same as a kilocalorie (kcal). So remember when you are trying to hit your 2000 Calories for your daily intake, you are really going for 8.4 million joules or 8400 kJ or just 2000 kcal. Got it? I just knew you wanted to know all that. A more visual summary below.