Yah the short answer is as Dugdog said there, it is based on satellites, time of flight of a signal (knowing those move at the speed of light and that is mostly known/fixed) it can essentially triangulate the position by getting a bunch of signals sent to the quad with known positions of the satellites and a timestamp.
Speed of light is about 3x10^8 m/s so say you are 10m away from a satellite the satellite will send a message out that says the time is T and I am at X, Y, Z. based on knowing the time and the position of the satellite you now know how far you are from it by simply multiplying the difference in time by the speed of light (in example if satellite is 10m away the time it takes for the message to get to you is 10/(3x10^8) or some very small time, the further away it is the bigger this time will be.
Since the GPS receivers don't have atomic clocks on them (very expensive) they use multiple satellites and relative positions to work out the actual time and then the position based on time of flight of the signal (I believe). There is probably some more advanced details being glossed over but conceptually that is how it works.
---
Regarding a physical GPS receiver module they come in two varieties with or without compass. Generally speaking there will be 4 wires for one with no compass and 6 wires for one with compass (really compass is different micro component but might be baked into same module). Red and black are power and gnd typically, then there is one pair for GPS that will send serial/UART data and has a TX and an RX pin, then if it is the type with a compass/magnetometer then it will have another pair of wires (usually yellow and green) that are for a I2C bus connection for the compass data. Basically I2C is setup where devices just broadcast on a shared "bus" (two wires) and you can have lots of I2C compatible devices on the same bus so long as they all use different addresses (I think up to 64) if using UART connection like the GPS part does it's a device to device direct connection so need one UART for every device (not all devices/subcomponents support UART or I2C though, have seen temp sensors use I2C typically simpler sensors that just broadcast will use I2C or where data rate isn't as important)