1g Carbs/protein = 4 cals, 1g fat = 9 cals
There are 3 main macronutrients (and alcohol). Each gives a consistent number of calories per unit of mass.
1 gram carbohydrate = 4 dietary calories
1 gram protein = 4 dietary calories
1 gram fat = 9 dietary calories
1 gram alcohol = 5.7 or so calories