A track circuit is used to prove vacancy of the track, not the presence of a train. Track-circuits are used in the operation and control of signalling equipment.
There are a number of types of track circuits in use but they essentially transmit a current through the rails to a receiver. If a train shunts the rails, the receiver reacts and the signalling equipment responds appropriately.