How can a smartphone's extended battery be same size as the original battery?
Usually just marketing
Most aftermarket batteries are labelled in way that is extremely optimistic (if not an outright lie).
It is possible to change chemistries to go to one with a higher energy density, but this is usually very unsafe as the phone's internal battery charge regulation circuitry is not tuned for the new chemistry and can cause a fire or explosion as a result.
It is also possible to gain capacity by utilizing the volume better. Most cell-phone battery packs have integrated safety electronics (current-limit, thermal fuse, short-circuit protection, and/or similar safety features). Using more advanced/smaller packaging for these electronics can yield more volume for active battery material.
Similarly, you can use more advanced/thinner substrates to get more active material into the same volume -- but these improvements are typically small (maybe no more than 10% in most cases).
So...
Yeah, it's probably just a fake product built on the (probably correct) assumption that nearly all buyers will not test the battery's capacity to verify the claim (e.g. they won't get caught).
This can be false marketing. This can also be more or less true and here's how.
First, battery technology slowly advances. One major power tools producer launched its 10.8 volts line of professional power tools in perhaps 2004 and they shipped with batteries assembled of 1Ah Li-Ion cells. In perhaps 2007 they switched to 1.3 Ah cells of the same size. Later they somehow found 1.5 Ah cells and 2.0 Ah cells still of the same size. Nowadays tools from that line come with 1.5 Ah and 2.0 Ah batteries. Newer batteries can be used on older tools and older batteries can be used on newer tools. I have no independent data to back the claim that batteries capacity indeed increases as claimed but batteries are key elements to power tools so I assume a major tools producer would not fool us like that.
Second, it depends on how you measure. You can charge the battery to different states. One major power tools producer claims certain Li-Ion batteries are charged fully in 35 minutes. Answers to this question explain that it's simply impossible and the most likely scenario is that the battery is actually charged to about 80% which isn't that bad. So if you know that the target device only charges a battery to 80% you can charge your battery to 100% when measuring capacity. Customers will be unable to use that full capacity but you can simply disclose your measuring procedure in the finest print available.
Third, you could find a battery with slightly thinner case which simply holds more chemicals and thus has larger capacity.
Fourth, you could find a battery that uses more compact safety features or lacks some of them. Major battery producers make some effort to ensure that batteries don't explode or burn under heavy loads. That also takes some volume of the battery. Make those less reliable or remove them - and you can fit more chemicals into the battery and get larger capacity.
Hypothetically, battery technology could have improved between the release of your phone and the release of the third-party battery. It's not very likely though, as the other commenters have said, given that battery technology hasn't moved much in the last few years.
My first mobile phone though, came with an NiCd battery. A later released battery, from the original manufacturer, was an NiMH battery, and was indeed both slimmer and had higher capacity than the original one (NiMH has up to three times the energy density of NiCd).
In the end I bought an NiMH battery even thicker than the original, and never had to charge my phone outside weekends. Those were the days. :-)