The relief that you get from washing your hands outweighs any pain or injury that you experience when your hands become raw from the constant scouring.
Think of the scales of justice, a scale with two plates hanging off either side of a bar, which is balancing on a point in the center of the bar. Place a weight on one side, and that side goes down, while the other side rises.
Using this image, think about relief from obsessive thoughts on one plate and pain caused by the rituals on the other plate. As long as the relief of the ritual outweighs the pain that it causes, you will continue to do it.
Only by facing your fear of not doing the ritual and realizing that the feared consequence will not occur will you begin to shift the weights on the scale and start to recognize that the damage you are causing to your hands is actually more dangerous than not performing the ritual.