If you’re writing a paper on your computer, it can be very easy to slip into a website that isn’t relevant to your paper. Likewise, it’s really hard to avoid checking your phone every 30 seconds if it’s right next to you. To avoid these distractions, make it harder to access them unconsciously.
If you can, disconnect your wifi while you work. You could also install a distraction blocker like Freedom, Cold Turkey, StayFocusd, or SelfControl to keep you from accessing distracting sites while you work. For your phone, turn off the notifications and keep it out of arm’s reach. If that’s still too much of a temptation, add more incentive with a phone blocker like Forest, which turns not using your phone into a game (that can double as a Pomodoro timer).