People with OCD often find the obsessive and repetitive behavior helps with anxiety, although the anxiety ends up reduced in the short-term, it worsens in the long term as the behaviors have negative consequences of their own (disruptive and time consuming, interfering with normal life activities, shame for lack of self-control).
We wouldn’t tell someone with OCD to just “quit doing that” (and for the person it would just increase anxiety to stop doing what helps their anxiety), but provide an alternative that addresses the core cause of the behavior (anxiety) and “unlearns” the harmful behavior, replacing it with self-help tools to address the core problems (anxiety) in ways that are less harmful and likely more effective in the long term. That can be done through a number of approaches, none of which are surefire and often take a few attempts.