My daughter hurt herself, too, when she was younger. She didn't want to, but she didn't seem able to help herself. She would get so frustrated and, unable to verbally express her thoughts and feelings (she had a speech problem), or even know what those thoughts and feelings were, she'd bite the back of her hand, hit herself on the head with her hands, or rock back and forth and hit herself on the wall or other hard surface. Sometimes she'd throw herself down on the floor and flail around.
With her, it was frustration at being unable to communicate. Putting her into Speech therapy for a severe speech impairment at the age of 3 (she's still in speech at the age of 8, and will be next year as well) has helped enormously, as did finding out she has Sensory Processing Disorder (SPD), a form of Autism. I'm not saying your son has SPD, but it's something to learn about and keep an eye on.
SPD is vastly overlooked, and many kids can be helped if parents and caretakers are aware of what it is, what triggers set it off, and how to deal with those outbursts. Does your son stay by you when he hurts himself? Or does he also run away? That's known as the fight or flight syndrome, which my daughter would do. She'll still do it, if we discipline her, she feels guilty or ashamed about something, or she discovers she's done something wrong. We have to work very hard on helping her not to run away, but to stay and work through the problem.
If your son continues to hurt himself, though, and is actually cutting/leaving marks, it might be a good idea to take him to see a Pediatric Specialist, who is either a psychologist or a psychiatrist whose specialty is dealing with children. We took my daughter to see a peds psychologist for a year when she was in kindergarten, and it made all the difference in the world.
Just my thoughts.
A. C