Because the issue is knowing where the other trains are, not yours.
Obviously it wouldn't be "just" GPS. In the simplest example - if I choose to add a friend to "Find my Friends" on iPhone, both our locations are visible to each other via GPS when our phones are on.
TCAS has solved this for airplanes. It wouldn't take much to modify the system for trains so that, in the least, it notifies when an unexpected train is nearby. A little more logic could allow it to verify which track each train is on.