The original iPhone didn't know where it was, because there was no satellite receiver in it and no positioning of any kind.
A modern phone works out where it is by combining inputs of wildly different quality and leaning on whichever one is least wrong at that moment, and indoors the input carrying the answer is usually Wi-Fi.
My friend David Coleman published the clearest short explanation of the modern version of this that I have read, and you should go read his post and its attached graphic. He walks through Fused Location Positioning, which is the reason your blue dot survives the walk through a lobby door.
Apple closed that lack of location awareness in January 2008, in software rather than in silicon. The iPhone could now triangulate its position using nearby Wi-Fi base stations or cellular towers.
Apple built neither of the databases behind it. Apple relied on databases maintained by Google and Skyhook Wireless. Wi-Fi access points on Skyhook's side, mapped by sending drivers out to record them, and the cell towers on Google's.
Between that update and the phone in your pocket, 3 steps did the real work: Assisted GPS arrived with the 3G in 2008. It moves the clock and satellite-selection work onto a network server, so the handset gets a fix in seconds instead of minutes and can work from a weaker signal than a standalone receiver needs.
Fusion became a platform service from 2013, when Google put it behind a single interface delivered through Play services rather than through the base operating system. From then on an app could ask for a position and let the platform decide which input answered.
Wi-Fi ranging became something an app could call in August 2018, when Android 9 exposed Wi-Fi RTT. That gave a phone a way to measure its distance to an access point by time of flight, using the Fine Time Measurement.
Apple describes its own Location Services in much the same terms: device sensors including GPS and Bluetooth where those exist, alongside crowd-sourced Wi-Fi hotspot and cell tower locations.
A satellite signal is already extremely weak by the time it reaches the ground, and it needs a view of the sky to be usable at all. Building materials take what is left of it. Wi-Fi has no such problem inside a building, for the least glamorous reason available. The transmitters are in the building with you.
Meter-level indoor positioning comes from ranging: 1 to 2 meters, measured against 3 or more access points implementing 802.11mc Fine Time Measurement.
19 years ago the iPhone could not find itself at all, and when the fix came it was somebody else's database rather than a better radio. The blue dot you watch hold steady as you walk through a lobby door is a Wi-Fi answer far more often than a satellite one, and it holds because the access points around you have already been mapped by somebody.
How many of the access points in your own buildings do you think are already sitting in somebody's crowd-sourced location database?