Turn off/silence all notifications while you work. Your attention and brain space is a precious commodity. Don’t let it be taken at the whims of others.
Try the pomodoro method: 45 min of focus, 15 min break. If that’s too much, start with less time for focus and a longer break and work up to more and more focus time: 30/30 or even 15 min of focus and 45 min break. Celebrate your accomplishments.