Train needs a massive upfront infrastructure investment, and isn't flexible for route when passing through politically unstable areas. China -> Europe needs to cross through at some point. Similarly, Africa -> Europe by train needs to cross in a politically unstable area. Being able to choose your route is very valuable.
The infrastructure for trains is already there (China -> Europe), its just static and therefore inflexible. It isn't going through politically unstable areas, just Russia. As long as you don't bet on one horse you're going to be fine. I don't know anything about trains from Africa to Europe. I believe China exports more than Africa.
Since we don't talk about last mile, they're competing with ship and airplane. For last mile, there's only the minivan/truck solution, though I'm not sure how widely adopted or sustainable drone delivery is as of now. A low carbon footprint of drone delivery would be a plus for adopting it long term.