I assume “how” is referencing the “change your habits” part, because getting off social media is simply a matter of choosing to do so, so I’ll answer accordingly.
Changing habits is not easy, in my experience finding hobbies you like is a great way to get out of your routine which then helps you notice what habits make you less happy since you’re no longer just going with the flow, but YMMV on that.
In general, it takes time and effort to vet your habits.
I’m not a professional, so I don’t have concrete methods other than my own, which is to “test” them: stop doing the thing for a week, assess how you feel afterwards, then go back to it and see if you feel better or worse.