Thats already the case for carriages within a train.... And people are fine with it.
We're also fine with the risk of a derailment onto a neighbouring track with traffic going the opposite direction. We could have tech which detects that, but we do not.
The thing you are missing is compartmentalization. A modern high-speed train can hold around 1,000 people. This is the maximum number of people that could die in an accident (ignoring trains on other tracks or people next to the tracks). What you are proposing is essentially a train of infinite length, with virtual (software) coupling between groups of carriages. But then there is no limit to the maximum number of deaths in an accident. If you have 50 high-speed trains all traveling in this virtually coupled manner, a single accident may cause 50,000 casualties. People would not accept this, and no sane policy maker would allow it.
Note that if you consider derailments into neighboring tracks, you still have an upper limit of 2 times maximum train capacity, in our example 2,000.