Masturbation is not a sin (transgression) for laypeople in Buddhism. It is only a sin for monks.
Masturbation is incomparably far safer than engaging in sexual acts.
Uncommitted sex with others leads to separation from the loved and other negative emotions resulting in sticky addiction, humiliation, shame & regret.
First off, Buddhism and karmic faiths generally don't really have a concept of 'sin'. 'Sin' is a Western conception — a feature of Abrahamic (Jewish, Christian, Muslim) faiths — that points at behavior that is punishable by some divinity. In karmic faiths, behaviors contain the seeds of their own consequences. Behavior that leads one astray isn't 'sinful'; ...
It hurts you, it is like buying something you know you can't afford.
It might hurt you less than doing something else but it still hurts you.
It is maybe not immediately evident how it hurts you but neither is living beyond your means immediately painful.
It is like stealing from yourself because you are with that conditioning your brain in a wrong way and ...