Sigh.
Railway crossings are pure evil. There is no fail safe design that I know of without adding a proximity sensor inside the car (I am a railway signalling engineer). Would love to be wrong though.
They have disadvantages including expense, and additional road closure times (compared to automatic half-barriers) as they must be closed and proven clear early enough that an approaching train does not need to slow down.
Confirmation comes from observation by a signaller or crossing operator either directly or by CCTV, or automatically by LiDAR and radar. These crossings tend to be used in areas of heavy road, pedestrian or rail movements, and when train speeds may exceed (from memory) 100 mph / 160 km/h.
Their disadvantage is additional installation, maintenance and operational costs. They must also be closed for longer before a train arrives than an automatic half-barrier crossing to allow for the required safety checks and ensure that signals are cleared far enough along the line that approaching trains do not need to slow down.
All safety mechanisms are this. The tricky bit is the value of life calculus. Is it worth an added $10/year tax for every taxpayer to MAYBE save 1 life per 5 years? You'll get different responses for different reasons.
That $10 may be a rounding error for many, but to some its the difference of a week of lunches for their kid or not, and they vote, too.