When a softball pitcher throws the ball, they use their leg to help generate power. This action is called the leg kick. The leg kick helps the pitcher transfer their weight from their back foot to their front foot, which gives them more momentum and makes it easier to throw the ball with speed and accuracy.
Some pitchers choose to hit their leg with their pitching hand as they go through the motion of the leg kick. This is done for two reasons: first, it can help remind the pitcher to keep their weight on their back foot; and second, it can help create a more powerful swing by adding extra momentum.