There are all kinds of solutions out there: take a break, only study for so long, always study at the same time, turn up the stereo, drink coffee or most useful, just memorize the data even if you do not understand it.
The last solution might work to get through the course but are you learning, just to pass tests? Although the passing grade may help you somewhat in life, understanding the data and being able to apply the data will help you more. This assumes the data you are studying has some value and workability in life. It is always possible you can not understand it because it does not make any sense. In short, there is nothing there to understand in the first place. But it is also possible there is valuable data there to be learned and understood but you can not grasp it for some reason.
To truly handle a problem you have to be able to spot the cause of the problem. So why do does attention wander?
Could it be that you went by a word or symbol you did not fully understand so now you can not comprehend what is being said or read? This could be a word that you know four definitions of perfectly but the author used a fifth unknown definition. So you have no idea that you do not understand that word. There are other reasons as well, you can also think you know words when you really do not. The trick is to go back and spot the word or symbol not fully understood.
This is covered in a book called Learning How to Learn.
The book covers when to go looking for a word or symbol not fully understood, how to find them and most importantly how to clear them up so you fully understand the word or symbol AND what you just read.
It also covers what to do when you are bent over while studying or feeling like you are spinning while studying.
If you read the book and apply the techniques just a little you will see a difference in your ability to study. The more you apply it the better you will do. By fully applying the data you can feel you can learn whatever you want to.