The moment the train derailed, panic broke out.

Literal

Train [subject-が] derail [as-soon-as-と], immediately panic state [to-に] became.

~と ('when, as soon as') at the end of a verb phrase is the temporal conditional — marks an action that causes another immediately. Often paired with たちまち ('in no time, at once'). パニック状態になる ('become a state of panic') uses the ~になる change-of-state pattern.