This looks like a digestible introductory guide: https://themedicalbiochemistrypage.org/digestion-and-digesti...
And a brief description of how all that helps inform calorie counts on nutrition labels: https://en.m.wikipedia.org/wiki/Atwater_system
People make entire career studying these sort of processes. Over time the information is refined. All of this ultimately helps inform how we measure and quantify things like calorie counts on food labels. Again, not perfect, but the process works and improves over time. It's a complex macroscopic system relative to the underlying chemistry and physics but if we assume larger systems are built on, composed, and governed by principles of constituent systems then we have a way of slowly understanding these complex processes and using that knowledge to our advantage.
Just as with software systems we rely on abstract processes below us to talk about things. That doesn't mean the high level abstractions are ignoring the details, it's just that there's value in talking about things simplistically like "calories in" and "calories out" without people looking to take very literal interpretations and trying to convert total energy possible into kcals. Heck, this is why they're "Calories" and not "calories" and why "Cal" has even been proposed to help avoid this sort of confusion.
If we looked at total energy of your gasoline we'd need to consider mass to energy conversion as well... but your body can't do that either. Energy your body can metabolize is clearly a subset of total energy available. It's certainly an estimate and it's not perfect but it's useful.