cellular network works on omni direction transceiver; which means your cell phone receives and sends signals to nearest antenna that careers has ever installed. the cellular company's network application can detect (and virtually see) the relevant antenna and locate your closest location.
Now, every wireless device creates an isolated connection with its peers as well as neighboring transceivers, if that frequency is tracked down using satellites, you actually detect the pinpoint location of the device, which in most case, is our pocket.
In land number, the idea is similar but the infrastructure is different. the whole process is manipulated in digital telephone exchanges. instead of wireless signals, exchanges already know who posses a particular number. however, it gets tricky when you somebody calls you from next door and the number shows (or gives impression) that s/he is calling from Cali. That is done by routing numbers or sometimes referred as masquerading.
In both cases, you have to have some legitimate authority to investigate. It is not public information, however companies are liable to keep track and its information saved for perusal.
Hope that clears the idea.