I am a human. I have behaviours. Some of them are unusual. The human sexual experience is vast, and through all of human history, people have tended to say "That person over there likes something different from what I like. Why? What event caused that person to like that thing?"
There probably isn't an event that causes a person to be a masochist or to like group sex, or to like being told what to do sexually or to like sex with partners of the same sex, or anything else and masochism is not of and by itself, an obsession.
There are a lot of reasons why someone might be a masochist, but it's important to understand what masochism is not. Masochism is not enjoying all pain just for its own sake. I have met many masochists but I have never, ever met a masochist who enjoys stubbing his or her toe, or getting his or her hand slammed in a door! Masochism is contextual. It's about liking certain kinds of pain in certain, usually sexual, contexts.
Most of the masochists I know enjoy pain not for the pain itself but for what it does to them. Many of the masochists I know get an endorphin rush from the right kind of pain in the right context. (Endorphins are the brains' natural painkillers, that can be released when we encounter certain kinds of pain. They can cause feelings of pleasure and euphoria.
It's also important to understand that sexual arousal changes the way we experience things. When you're sexually aroused, things just plain feel different. Something that's painful in an unpleasant way when you're not aroused can feel very different when you're aroused.
None of this is caused by any impression or event. It's all part of how our brains and bodies are wired, and it's all part of the normal variability of ordinary human sexuality.