What exactly causes muscle spasms after death?

This morning I saw a cat getting its head crushed by a car. It was pretty disturbing to see the body. But afterwards, the cat bounced around for a minute, having wild spasms that launched it over a meter high (from its side). Why does this happen? And can humans spasm that much after death and what would need to be the conditions for that to happen?

I don’t think what you saw occurs with any death. What you were witnessing was the process of dying from a massive head injury. I suspect, then, what you saw were seizures (i.e. convulsions, fits, ‘epilepsy’) and they were a consequence of the head injury, not the death.

IANAV YMMV

Yeah I know it doesn’t happen with every death, which is why I asked under what circumstances. I just wonder what exactly causes this to happen in the absence of the brain, which has been crushed to a useless pulp.

A crushed brain is not the same thing as an absent brain. A crushed brain will have neurons discharging wildly and chaotically as it dies. That’s most likely what you saw, seizures induced by massive cerebral trauma.

Wonder what that feels like? Hope I never find out.

How does that explain chickens then, which do the same thing (warning - chicken gets beheaded and flaps around) as the cat described by the OP?

I’m not a vet, I’m an MD. But as I understand it, the chicken brain is quite primitive, and a lot of basic motor activity is programmed into its hindbrain, which is still left behind when the head is cut off, unless the bird’s head is removed very low on the neck.

Hence The Case of Mike the Headless Chicken.