To make this pretty simple. There are a lot of allowances allowed by the FDA and in other countries it can be even more lax. First the companies can use basically who ever they want to do calorie/analytical analysis. They can choose from 1 of 10 reports they get to best serve their target audience. To take it another step there are also rounding considerations that they get.
So if you have BLACKBEAN A vs BLACKBEAN B they are probably exact the same unless they have sugar/additives in the "sauce". But If BLACKBEAN B is targeting the protein crowd then they will obviously use the report that calculates the most (amount of protein) that they can round up to. But at the same time the amount of total calories has to be correlated with the amount of protein too (and fat/carbs). So by reporting more protein they are now the higher caloric choice. Just marketing. BLACKBEAN A gets the lower calorie target audience by reporting less protein. Same beans.
What happens if a company is wrong? Not much. If a consumer group or FDA comes in and says calorie info is wrong they just have to change it - if they don't they get fined. Really companies don't go too far off because of the bad press they would get.
The FDA is really concerned about the ingredients and accuracy there. It is really the most regulated part of the information that you get from packaging.