Cribbing liberally from Manfred's answer on a related question, it basically works like this:
The airline contracts with a communication company and installs satellite transceivers and "small cell" cellular equipment on their aircraft. Your phone talks to the on-board cellular equipment just like it would to a cell site on the ground, but the information is relayed to the satellite and sent back to earth to join the regular telephone/data networks.
It's not generally feasible to use these datalinks to track the location of the aircraft -- getting your basic position (latitude/longitude) requires triangulation from at least 3 satellites, while data communication only requires one (satellites are expensive, so providers aren't likely to launch their own constellation of satellites to duplicate the functionality of GPS).
This same type of data uplink could theoretically be used to transmit flight data (including GPS position that the aircraft can get from the existing GPS equipment on board) back to the airline's headquarters, ATC (to fill gaps in RADAR coverage), etc., but I'm not aware of any system or plan to implement that currently.