Similar concept to GPS but instead of satellites (which aren't so good when the trains go underground or even when they are above ground but have high building skyline obstructions) the train positions itself based on time-of-flight pings to these beacons with known locations and using multilateration to figure out where the train must be based on the distance information.
Source: Working for a company in San Diego (but travelling to NYC often) I wrote a now surely obsolete version of the positioning code (running in MISRA C on what were basically Raspberry Pi devices installed on the trains) back during the proof of concept phases of this system when it was only the 7 line 5-ish years ago back when Andy Byford was still running things.
Spent a lot of late nights on 7 line trains doing real world tests (exciting when we tested the failsafes and the train had to e-brake!) and had to get trained up to be able to walk the rail lines as we'd often be installing the track-side beacons ourselves during low traffic transit times (which is to say, usually in the middle of the night).
If you watch the video here:
https://www.railwayage.com/news/positioning-the-next-generat...
and go to 1:32 you can very briefly see another thing I wrote there, an app which would take the positioning information in real time and overlay it on to openstreetmaps data.
That app was written in Qt/C++ and wasn't even really part of the system, it was just something I wrote to make it easier to debug any problems with positioning when we could visualize them in a real world context. Generally the only time you'd have positioning errors to debug were due to some of the beacons having incorrect coordinates (I'm sure they've ironed this out a lot since the PoC). The debug app ended up being nice and flashy for the media attending the PoC demos though (more exciting to look at than some text logs) which was a nice side benefit.
And then there's the cellular carrier stuff that's been put into many stations, which generally is easy to pick out because it's relatively new/clean and has distinctive antenna types.