I am somewhat confused by this thread since this is well known and can be googled.
There are multiple ways to compute percentage of protein/fat/carbohydrates but only a few are used by any feed manufacturer:
1) As a percentage of DRY matter
2) As a percentage of "As Fed" by weight
2) As a percentage of calories
For 1) this is done by weight of dry matter. To do this, you must know the moisture content of the item. Once you know the percentage of moisture you can calculate the total dry matter and use this to determine percentages of protein/fat/carbohydrate by weight. This is what is meant when people say that you need X grams of protein per day or on food labels that indicate values on a dry matter basis.
For 2) this is done by providing percentages of total weight including moisture. This is typically what is seen on food labels that read "As fed". Because this includes water weight you cannot use this value to compare disparate types of foods (think dry dog kibble vs. raw meat or raw egg vs dry grains) without converting to method 1 or method 2.
For 3) this is done via total calories vs calories generated by protein/fat/carbohydrate. Calculating this way will always show fat as much higher than carbohydrates & protein (4 calories per g) as fat (9 calories per g) has more than 2x the number of calories for the same weight. This is what you see when food labels tell you that an item is X% of a 2000 calorie daily diet.
You can only compare values computed via the same method and sometimes you need to do some sleuthing to determine what method is used on a feed label. It does not matter which method you use as long as you are consistent and don't compare values computed by different methods or use method 2 to compare foods with different moisture content.
Here are a couple of links that have some background on computing protein levels in dog food (similar concept - you can ignore the raw vs kibble debate and focus on the math):
https://www.dogfoodadvisor.com/choosing-dog-food/dry-matter-basis/
https://therawfeedingcommunity.com/2017/07/21/raw-diets-too-high-in-protein/