I've been there, first a grad student and now a professor. I also teach people about how to write, so I follow the research on this. First, as you age, this will happen some; it started for me in my early 40s. Second, you don't need a lot of these distractions. You might get push-back from people; you might think you need this stuff, but start aggressively using airplane mode on your phone. Use software on your computer that blocks distracting domains for a set period of time, or even go somewhere without internet access to work. Or leave your networked devices at home. Simple. Third, the body is part of this, nutrition, sleep, cardio exercise, are all shown to have significant impact on ability to concentrate. Fourth: pay attention to your moods, set work goals, don't whip up on yourself while making yourself work, etc. Fifth and final: keep all activity sustainable and form good habits (avoid bad habits like butt-chugging caffeine, popping Ritalin, or maintaining a marijuana fog).