While the pomodoro technique and the urgent/important priorisation has already been mentioned, here's my personal suggestion, which includes both of them in some form or fashion:
- If you don't already have it, use an acceptable calendar app, shared between your PC and smartphone, one that integrates well with your mail system and whatever your colleagues are using.
- Meetings will be in the calendar anyways, probably.
- Now start putting everything in there. Especially if you intend to work alone on a topic, be sure to block that out. Don't forget break times (lunch etc.) - enter them as well.
- At the beginning of each day, check your calendar for today (this will also be your first calendar entry each day - "Clean up today's calendar"). Look for all conflicts and resolve them by moving them around, maybe cancelling invitations or not so important events. Here, the urgent/important distinction becomes important, of course. Your calendar for today should now be completely filled. Not only with work - there will and should be breaks in there as well, but they should be there explicitly.
- Configure your system so that mails do not pop up notifications, but your calendar does.
- Now comes the hard part: when your calendar tells you to switch to another topic, do it religiously. If you have not finished your current work, immediately find a new time slot (tomorrow or maybe today if there is another event which is not so highly prioritized) and plan it in there.
- When your 8 hours per day are up, or however much it is, stop working. Don't fall into the trap of doing everything that fell on the wayside during the day at the end.
Over time, this trains you to be methodical and realistic. If you notice that your time slots regularly are too short, then you might have to fine tune the size of those slots (for me, that's usually 30-60 minutes; 120 minutes very seldomly), or reduce the content you put in there. You want this to be a game: being done with what you intended to do in a slot should give you a little spike of joy.
You can and probably should, at least at the beginning, have buffer time slots; i.e. plan in an hour a day (or maybe one in the late morning, one in late afternoon) as a pure buffer. As you get used to it, this might not be so necessary anymore. If you run out of stuff to do in a buffer, do whatever - either take a walk, or pick anything else you wanted to do later, and pull it forward.
Reading your mail is an activity like any other - put in a time slot for it, and if possible avoid checking your mail all the time or at least ignore mails coming in during the day as best as you can (you might still look there to get updates on the things you are workin on right now).