This is kind of long but I tried to make it as simple as possible.
The term “GPS” is used two different ways.
Originally it referred to the Global Positioning System satellites first developed in the 1970s by the US military and made freely available to the public in the 1990s.
Today “GPS” is used loosely to mean all the ways a smartphone locates itself using signals from the satellites, cell towers, wifi hotspots, etc. Because each method has its drawbacks, your phone tries them all and comes up with a good answer.
I am writing now only about the first one, the satellites.
1) The satellites have super-accurate clocks and their precise positions are known.
2) Each satellite broadcasts a signal saying “Here is the exact time and my exact position”.
3) The receiver compares signals from four or more satellites.
4) The time they arrive differs with distance – the farther satellites time signal will look be a little bit behind the closer ones.
For example, if a satellite is 10,000 miles away it takes about 3.2 seconds for the signal to travel. 12,000 miles takes 3.9 seconds. Let’s say there’s a 3.8 and a 4.0 also.
5) Your phone (a little computer) can do the math and figure out the ONE place where you would be 3.2 seconds from satellite A, 3.9 seconds from satellite B, 3.8 seconds from satellite C and 4.0 seconds from satellite D.
6) Or imagine you are in a room with the satellites. You have a stick 3.2 meters long and a stick 3.9 meters long. And a couple more 4.0 meters and 3.8 meters.
There is exactly ONE place in the room where you can touch the four satellites with those sticks. Move just a little bit and you won’t be able to reach one or more.