While these events are statistically very rare, it is worth remembering that there have been two separate events in the past twenty years in Spain where high-speed trains have derailed leading to multiple fatalities [1][2]. In contrast, the Japanese Shinkansen has a spotless record since its introduction in the 1960s [3]. Not a single fatality due to a crash or derailment. And that's in a country with a much larger population and much higher passenger count per year.
What do they do differently?
[1] https://en.wikipedia.org/wiki/Santiago_de_Compostela_derailm...
[2] https://en.wikipedia.org/wiki/2026_Adamuz_train_derailments
[3] https://en.wikipedia.org/wiki/Shinkansen#Safety_record