What is the density of carbohydrates/protein/fat?
I assume the "energy density" you are referring to are the widely known statistics that:


fat contains 9 "calories" per gram (actually kilocalories)
protein and carbohydrates both contain 4 "calories" per gram


How can all fats contain "9" kcal per gram but have different mass densities?  Here are a couple of reasons:


The 9 kcal/g figure is an approximation that assumes a typical dietary blend of fats.  The figure would if considering chemically pure fat molecules.
The mass densities of most common fats doesn't vary that much.  The densest "fat" molecules are probably the extremely short chain triglycerides like triformin and triacetin.  They have densities of approx. $1.3~ \frac{\mathrm g}{\mathrm{cm}^3}$.  These triglycerides have chain lengths of 1 or 2 carbons per fatty acid chain, a value far lower than common in natural fats.  Triolein is more representative of dietary fats and has a density of 0.95$~\frac{\mathrm g}{\mathrm{cm}^3}$.  So the mass density variation among different fat molecules is pretty small: a 30% increase is all that is really possible.