I have major attention problems...I can't seem to focus on one thing for more than 5 minutes before I get distracted!

I'm writing an essay for homework. BAM. I'm suddenly watching Youtube and my essay is hardly finished.
I'm researching for information on something. BAM. I'm suddenly checking my email and talking to my friends.

This results in me getting stressed out for having lots of unfinished work due tomorrow, or it results in procrastination. It gets me stressed out but I don't know what to do about it.

What can I do to make myself focus? Please help!!