Macros are +-20% and typically based on standard measures rather than directly measuring, they will calibrate for weight/volume based on the NIST standard ingredients and then use that to calculate the macros.
Most prepared food will use 4-4-9 from macros to calculate calories. They can also use a component based method which foods purporting to be healthy tends to use as 4-4-9 will overestimate calories.
4-4-9 is a good guideline but the actual number of calories varies by source. Plant based sources typically have lower calories per gram of fat & protein but higher calories from carbs, animal sources are reversed.