After getting this question a few times and remembering back to when I was also confused by the concept I thought I would do a quick post about what I have learned.
Here is what I know now. Your total calories are comprised of the grams of energy/calories produced by these 4 Macro-nutrients (Macros for short) Fat Protein Carbohydrates & Alcohol. (Vitamins, minerals & sodium are Micro-nutrients and do not contain calories) One Gram of Fat = 9 calories, one gram of Protein = 4 calories, one gram of carbohydrates = 4 calories. Alcohol=7 calories. And you obviously don't need alcohol. On a ketogenic diet you are setting your Macros to certain percentages. typically 65-75% of calories from fat, 25-30% from Protein and 5-10% from carbs. So for example when my calories are set to 1500, I use 70/25/5% as my guide which gives me 117 grams of fat, 94 grams of protein & 19 grams of carbs as my goal. I obviously rarely would hit that dead on but it's what I would shoot for. I would look at the percentages on MyFitnessPal and see if I was close in range to those percentages I mentioned above. Always trying to get my fat just slightly above my protein with every meal and getting no more than 20 net carbs. When drinking a protein shake or eating a protein bar I often will have something with high fat and it like macadamia nuts or almonds to balance out the fat to protein ratio. Hope that helps. Feel free to add additional questions in the comments or correct me if you notice a send something wrong.