Probably because Tesla undersells their batteries. During hurricanes or other disasters Tesla routinely unlocks the software limit, allowing customers more range (https://www.teslarati.com/tesla-unlocks-full-battery-capacit...).
It's the same with HDDs and SSDs, which always carry a decent safety margin to account for media wear.
For kWh capacity it's just a matter of counting the cells. Actual kWh will vary abit by measuring technique but I assume there is a way to drain the nominal Wh:s from them.
https://www.greencarreports.com/news/1110149_tesla-model-s-b...
"But, overall, the data offer some basis for confidence that a Tesla Model S will lose—on average—less than 15 percent of its battery capacity over the average 150,000-mile (250,000-km) life of a vehicle."