Last month a friend was telling me that he and his co-workers had noticed a person across the street from their office every morning would walk a weaving pattern between the columns of the building. And if pedestrians blocked his way, he would wait until they left and then scurry to the opening to make sure he completed the pattern. I gather they all chuckled a bit at the realization, but then my friend asked, "Well, what are your compulsions?"
He was astounded to learn that many of them had to have all the papers on their desks "just so". They have to have their edges parallel and perpendicular with exactly the same amount of space between each sheet or pile of sheets.
So I asked him what his compulsion/obsession is. He and his wife both laughed. He says he has to leave a tip that makes the bill come out to an even figure on the credit card (he is a generous guy and undoubtedly rounds up to, e.g. $90 instead of $88.77 or whatever a 20% tip might be). The reason they laughed is that every time his wife leaves a tip she purposely makes it come out uneven, just to bug him.
Someone else I know is hung up on fours. They have to eat four crackers. Or four groups of four crackers, etc.
[Addendum: I met someone the other day who says that whenever she's in a library, she has to make sure all the books on the bookshelves around her are straightened before she can do any work herself.]
My friend then asked about my obsessions. I'd been thinking about it some even before this conversation, and I realized I have a very minor hang-up (!) with coloured plastic coat hangers. When I take things out of the dryer, I try to match the colour of the item with the colour of the hanger. But it isn't serious. If they don't match, I just hang them on whatever is available.
Later I realized I have a more serious compulsion. I count stairs. Whenever I go up and down stairs, I count them. It's not a complete obsession, though. If I'm walking with someone else, I don't count them.
I have no idea how this pattern got started. Probably some form of reinforcement at some point in my life.