Compulsion vs Habit
Compulsion
Done to reduce anxiety or prevent a feared outcome; often feels driven and hard to stop.
Habit
An automatic routine, often neutral or rewarding, without a feared consequence attached.
where they overlap
Both are repetitive.
the key difference
Why you do it, and how distressing it is not to.