In The Force Awakens Kylo Ren is shot in the side by Chewbacca. Later on in the forest, we see him hit himself repeatedly in the area where he was shot.
Why does he do this?
Wouldn't that, like... really hurt?
I think there's a much simpler answer.
Hitting a part of your body that is causing a distractingly sharp, acute pain can numb that pain by turning it into a blunt, dull, persistent and therefore less distracting pain. Basically flattening the pain by maxing it out.
This is something I've done in real life when sharp (non-wound...) pains like cramp or muscle strain momentarily prevent me from doing important things. I wouldn't recommend it... But it feels like it helps at the time, for a few seconds at least. I'm sure I've seen lightly-injured sports players do it, too. I'm trying to find a reference to link to, but all I can find are disturbing self-harm advice pages which I don't want to link to... But it is a thing.
It's also a (self-defeating) way to vent anger and frustration. Kylo does this at times his opponent is too far to lash out at.
Of course, this is not a sensible thing to do, because it makes the actual wound worse, and the numb feeling wears off in seconds - but we shouldn't expect Kylo to be behaving sensibly at this point.
It's been well established that he doesn't cope well with anger, and at this point he's even more of an emotional mess than ever - not just for the obvious reasons, but also because his prime motivation seems to be a fear of failure/mediocrity and at this moment, not only is the plan is on the cusp of failing, but also, with his injuries and his inability to focus, he's struggling to defeat two people he should defeat easily.
The pain from his wound is distracting him and compromising his ability to beat two enemies he should defeat easily - and he's lashing out in characteristic fashion, trying to literally beat the pain away.
Not sensible, but perfectly in-character.
From a storytelling point of view: - it reminds the viewers that he's injured from Chewie's shot, is struggling to focus, and is not at all at his best, and could pre-emptively answer the question "Why is such a powerful character struggling to defeat two characters who have little to no experience with lightsabers?". The clips where he beats his wound also include other similar reminders such as, visible blood on the snow, him hunched over momentarily limping, him roaring in frustration, etc.
Judging from how this scene is discussed, I suspect it maybe didn't succeed in communicating this to all viewers...
According to Wookieepedia:
Kylo could be seen beating his wound to utilize his pain and tap into the dark side of the force.
Rather than his perpetual state of pain handicapping him, it fuelled his rage, allowing him advanced control of the Dark Side of the Force. The same used to be true of Darth Vader back in the day. It's a special case of Force Rage:
Force Rage, also known as Dark Rage, Force Enrage, or Force Fury, was a dark side alter Force ability. The Force user would tap into his or her innermost fears, pain and hate, and convert them into an intense rage. The user could then channel the anger to increase his or her own speed, strength, and ferocity. However, the body could not handle such rage for long periods of time, so the user became greatly weakened for some time after the rage subsided. If light side users wielded Force Rage, it could permanently disrupt their connection to the light side unless something happened to interrupt the Rage and bring them out of the dark side's grip. Therefore, the Rage could give the wielder an instantaneous physical and mental response, but pull them into deep depression, physiological harm, and the endless void of the dark side.
Kylo Ren is hitting himself in the side as a metaphor, in a way. He is distracting the pain he now has internally by causing greater outside pain himself. We can see that reflected in the idea that Ren has suffered a great emotional pain, and is now using the dark side of the force to create a greater outer pain socially in the world than the pain he feels inside to make his own feel more bearable.