The signalling system is designed so there's no possibility of an oncoming (or path-crossing) train. On a modern system this is done with formal proof of the software, on an old system with mechanical interlocks.
Yes, and if you maintain it very well you will never have accidents. That's why Poland never has railway accidents, perfect maintenance and everything 'just works' /s.