Re: medical or mental? To the best of my knowledge: yes.
It’s called vasovagal syncope and it’s a stress response, so it is psychological, but it can be an unconscious trigger – I didn’t know I had a needle phobia until I’d had dozens of vaccines and blood draws and connected the unpleasant responses to the cause. As in, I thought I kinda enjoyed injections and didn’t mind needles, so had no idea why I was passing out and convulsing after vaccines until it suddenly “clicked” a couple years ago.
Furthermore, it seems at least partly genetic. Your mind and body aren’t really separate, after all – mental *is* physical. But vasovagal syncope tends to run in families. My dad used to get experience it whenever he saw blood. Blood doesn’t bother me, even my own – it’s just the needles and the sensation of having things added to or removed from my body.
basically vasovagal syncope is you seeing that you’re getting an injection and your lizard brain going “actually no, I think our whole goddamn limb is off, we need to force a shut down to prevent bleeding out, probably”