That is only possible with fully standardized train units. Which is why you will see this in subways and dedicated high speed networks, but not on the common rail net. Platforms on a larger railway station have to accommodate a range of trains, from metro services (many doors at shorter intervals), to intercity trains (fewer doors, longer carriages), to special trains like night trains (a bunch of carriages from different ages strung together) and rented locomotives with spare carriages to fill gaps in the roster caused by late delivery of new trains.
> Making sure the rails are not accessible with fences around them.
There will always be spots where the rails are somewhat accessible outside of built-up areas.
Besides, all of that is fighting symptoms. Spend the same money on prevention and you'll have much more impact.