A high-speed train slammed into the rear of another that had stopped, derailing two carriages, authorities say.