CAIRO — Two trains collided in southern Egypt on Friday, killing at least 32 people and injuring 90 in the latest disaster to strike a railway system that has long been plagued by accidents, poor maintenance and mismanagement.It was not immediately clear whether the authorities suspected sabotage or an accident. But the Egyptian National Railways Authority said someone had activated the emergency brakes in some cars on one train and another train coming from behind crashed into it, causing two passenger cars to overturn. Tens of ambulances rushed to the scene near the city of Sohag on the Nile, about six hours’ drive south of Cairo. A video shot by a passenger and posted online showed a frantic scene inside one of the cars, where people appeared to be trapped. “Save us,” one of the passengers is heard screaming. “We can’t get the people out.”President Abdel Fattah el-Sisi of Egypt promised in a post on his official Twitter page to penalize those responsible. “The pain in our hearts today will only increase our resolve to end such disasters,” he said.The collision came as Egypt was dealing elsewhere with a major crisis on the Suez Canal, where a cargo ship that ran aground has halted traffic for days on one of the world’s main shipping routes.Egypt’s creaking railways have a terrible safety record, with deadly crashes, fires and collisions at signal crossings a frequent occurrence. In 2002, the country’s worst rail disaster claimed more than 300 lives when a fire erupted on a speeding train traveling to Cairo from southern Egypt.At least 20 people were killed and dozens were injured in 2019 when a train crashed into a platform at Cairo’s main rail station, setting off a fire. A year earlier, a passenger train and a cargo train collided in the Nile Delta north of Cairo, killing at least 12 people. In 2017, two trains crashed near the port city of Alexandria, killing at least 37 people and injuring more than 150.The government statistics agency reported 10,965 railroad accidents between 2008 and 2017. The 1,793 railway accidents reported in 2017 was the highest number of accidents the country had seen for at least 15 years. While investigations and inquiries are often ordered up after crashes, little has been done to solve the longstanding problems. After one crash in 2018, Mr. Sisi said the government lacked the roughly $14 billion needed to overhaul the run-down rail system.“The last fatal accident happened a while ago so this is not necessarily a sign of negligence or a recurring problem,” said Reda Abou Harga, a former deputy head of safety and former spokesman for the Egyptian National Railways authority.But Mr. Abou Harga, who retired shortly after the 2017 crash, acknowledged that the train system was in need of an overhaul. “The state is undertaking a comprehensive railway development plan,” he said. “They know it’s an absolute necessity and are finally putting money into it.” Some of that money comes from the World Bank, which approved a $440 million loan to Egypt this month aimed at modernizing the signaling system, upgrading track work along hundreds of miles and improving safety and quality. According to the World Bank, however, the project is an extension of an earlier one that concluded last year and failed to achieve many of its targets. Instead of slashing the average number of fatalities from railway accidents by half over the last decade, for example, that number more than doubled.At a news conference, Prime Minister Moustafa Madbouly reiterated the government’s plan to develop the railway system, saying that billions had been spent but that progress had been modest. “There are tens of thousands of trips and millions of passengers moving each day,” he said. “We are developing the facility but it will take time and one challenge is that these accidents could happen.”Anna Schaverien contributed reporting from London.