I got three simple advices & tools that work well for me.
First: Phone away
Never take your phone with you, even if you have breaks. When I have my phone, I always end up taking more breaks, even if I set a limit. I also get lost on social media easily. Putting your phone away and in airplane mode (or giving it to a person you trust that can keep it the time you study) will always work.
Two: Use podomoro
Podomoro is a small tool that you can easily download on Mac or Windows. It sets a timer: 25min for work, 5 min for break. It works so well and forces you to focus and not lose time. Still the best productive tool I tried. Also works with a watch. I often end up working for 3h+ without watching the time with this technique.
Three: If, even when you put your phone away, you still check social medias or distracting websites, use Cold Turkey.
Cold Turkey is a software that blocks websites. You can set the time, choose the pages you want to block, etc. Super useful as well.
Combining those 3 works really well, especially if you're often using your computer.