Maintaining focus can be difficult, especially in this age of social media and entertainment, but you should at least try to remove distractions when you set aside time to study.
It may help to listen to LoFi study music or something similar to help you focus, if you don't like sitting in silence when studying.
During class, keep your phone out of sight so you can focus on what your instructor is saying. If you are using your laptop for note taking, close out of any unnecessary browse tabs. You don't need YouTube up if your taking notes. It takes a lot of will power, but you can do it! Give yourself a chance!
If you can help it, try to avoid procrastinating until the last minute. This can cause a lot of unnecessary stress and anxiety. If you manage your time well, give yourself a few extra days to complete a task, because some days it may be hard to focus, other days you can dive right in with no issue.
If you find it hard to focus on something, it is okay to step away from it for a time and come back later. Give your mind and your eyes a break, then return to the project at hand. Just be careful and don't take too much time away from completing your assignments.