The first train going from A to B derailed, and the second train going from B to A crashed into the derailed cars 9 (20 on other sources) seconds later. Even if the second train was put in full brake in the exact same second the derailment happened, it couldn't have avoided the crash.

https://en.wikipedia.org/wiki/2026_Adamuz_rail_disaster