According to the OED, stat in this sense originated in pharmacology. The word stat would be written on a prescription to mean "immediately". The OED gives two citations for this:

1875 — W. H. Griffiths Lessons on Prescriptions iv. 18: "Stat., immediately."

1971 — Lancet 25 Sept. 700/2: "Stat., to be given at once."

The word stat is an abbreviation of the Latin word statim, which has the meaning "instantly/immediately".

This usage was then generalized beyond the domain of prescriptions to refer to any action that needed to be taken immediately.