If you have trouble with paying attention or staying focused while doing homework or studying, here are some tips that helped me:
1. Try listening to music while studying, I recommend listening to calmer music like lo-fi or classical instead of really loud upbeat songs. The music will help serve as a background noise for your head, so that you stay focused on your studying.
2. Make mini goals for yourself. For example, tell yourself that if you spend 30 min studying then you can spend 10-20 min watching YouTube (remember, don't take more than 20 min!) or do something you enjoy. I found that this really helped me, when I have something to look forward to after studying I feel more motivated.
3. Make a checklist of things you need to get done. I find it really satisfying when I'm able to mark something off my checklist, it helps motivate me to finish more things.
4. Time yourself when you study. Get into a routine of having a specific part of your day be "study time". At first start out at 20 min, then 30 min, then 1 hour. This will help you get into the habit of studying.