As many people rightly say, you aren't expected to work for 8 hours in 8 hours. However, few of the answers answer your main question that you stated after the edit:
What could be the best approach for me to get more efficient?
If you are taking hours-long breaks browsing the Internet, as you say, this goes beyond guilt over the occasional brainlag or too many smoke breaks.
I would guess that there is one main reason why you are having a hard time focusing:
I'm usually several weeks ahead of schedule
Sure, the whole project isn't done, but the part expected of you is done, and so is the next part and the next part. Not having anything immediately significant to work on, with the parts you're supposed to be working on already done ahead of time, will reduce your ability to focus - if what you're doing isn't significant right now, that may prevent you from caring much about working on it right now.
Your manager has decided that you should, as an intern, work on one project. This does not seem to be enough project to fill your time. It also does not seem interesting enough to occupy your attention for most of a work day.
Either:
A) Ask to move the deadline up.
I don't know if you have a paid internship, or how that pay is structured if it exists, and obviously if you do move the deadline up you run the risk of putting yourself out of work sooner if you finish the only task they want to give you sooner. If you want the deadlines to be sooner, you should also ask if you (and your manager) could plan for another project if you want work after the project is over.
-or-
B) Ask for a second project to work on that is substantively different from your current project and that you could definitely use for gaining experience.
Probably the best approach. Again, ask for something significantly different from the project you are working on. If there's no other project on the horizon, ask for any interesting work at all you could do on the side, improving database indices or whatever. Don't say you haven't been working full time, but explain that you now have enough of a handle on your current project that you would like to pick up a side project to help expand your horizons, and that going forward your current project may not be enough to fill your time. Your manager may ask you to complete your current project sooner (see option A), but hopefully he or she will see the wisdom in your request.
Either approach has the potential to impress your manager if you're gunning for a permanent position with the company when your internship is over. Just make sure you don't talk yourself into working yourself out of a job if you're getting paid.
switch
statements.