There are a couple of ways to get additional capacity out of a battery the same physical size, all of them bad. You can make the insulating layer between cells thinner, allowing for more of the battery to contain chemistry to generate power. At the risk of leakage and fire.
The other way is to play with the circuitry in the battery that reports charge levels to the phone. All name-brand Li batteries leave some margin for error, so that when it reports 100% it's not really quite fully charged, and it reports 0% before it's totally drained. It's possible to build a battery without that safety margin, so it will last a bit longer on a charge. But overcharging Li batteries is very bad for battery life, and draining them completely is also bad. So a battery that uses this technique will wear out a lot sooner. If you've ever seen a battery swell, so the sides aren't flat, that's probably a sign of overcharging.
But I think most of these aftermarket batteries don't use either technique, and the capacity claims are just flat out lies.