Years of neglect and a lack of funding have left many of southern Africa’s rail lines limping along despite growing demand for trade routes for critical materials used to produce electric vehicles.