Agree with others, sometimes autistics don't experience empathy in the same way or don't have the ability to interpret the information that's necessary to have and then show empathy. Sometimes they don't show it or show it differently. And sometimes they show it, but because they're a neurodevelopmental minority the empathy being shown is not recognised and is misinterpreted.
On that last one, about being a minority, what I mean is that the average person can look at what's happening to another person, imagine how they would feel in that situation and what they would want people to do, and they'll probably be pretty accurate in guessing how the other person feels and what they want. But if I as an autistic person use that same process, I'll likely as not get it wrong.
So for me, when I'm upset or hurt, it takes a lot of my mental effort to process and manage that, and I don't want to have to manage the high cognitive burden of social interaction (analysing someone's words, tone, body language, facial expressions and intentions, and formulating polite but productive verbal responses while producing appropriate tone, body language and facial expressions), on top of dealing with my pain and/or distress. I especially don't want someone touching me, because with my defences down and my state of arousal high, social touch feels intense to the point of pain.
If I were to do what the average person does when they see someone else who's upset or in pain — that is, if I think how I would feel, and treat them accordingly — then I would leave them alone. (Additionally, some things don't feel as painful to me as they apparently do to others — being punched in the playground didn't hurt me much, so it confused me when kids made a big fuss about being punched but were fine with things I found painful — again, I could do exactly the same thing average people do — think how I would feel in that situation — and come out looking less empathetic.)
I have been able to learn to override the instinct to leave people alone when they are upset or hurt, and instead to talk to them and touch them, and I have learnt techniques to deal with the extra distress people cause me by talking to me and touching me when I am upset (if retreating somewhere is not an option), and to suppress my own needs in order to not be rude to someone who thinks they're being nice.