I was having a chat yesterday to someone about exactly this. Looking at my grades you'd hardly recognise that I have an extremely short attention span. I always need to be stimulated, and now I've learnt how to make this work for my learning. I have days where I literally need a phone break every 15 minutes because that's how long I'll last before my mind starts wondering and I don't take the lesson seriously anymore. In Uni lectures, I used to feel like I had to get up and get out, but now I've realised that even just scrolling through photos on my phone is enough of a distraction that I can still be listening to my teacher/professor, but it's just enough distraction that I can engage mindlessly with photos on my phone. I like fast paced activities, and I know how I learn best. You can't do a whole lot in class without speaking to your teacher and saying, "hey, I'm struggling to pay attention and it's not you, it's me." Hopefully your teacher will appreciate you communicating about your struggle to stay on task and will be able to organise with you some suggestions. For me, I literally need to zone out for a few minutes and do something mindlessly while still listening to my teacher, and then I came back to it. Maybe doodling on your page in class is enough to get you through.
Then, when you're at home, you need to be more creative with it. Consider: Will you benefit from putting your phone away for 30 minutes and then having 10 minutes of study? Do you study best outside, where there's lots of minor things to distract you for a few sections while you're studying so you always feel stimulated? Or do you study best in utter silence so there is nottttthing to distract you?
Like I said, I recognise my attention span is remarkably short, but removing all distractions doesn't help me. I need to keep some distractions around in order to stimulate my mind for a few seconds, maybe a minute, and then I can drift back into study again. It's taken a while for me to become comfortable with this, I used to fight it and force myself to not be distracted at all. But giving in has actually proven very effective, and now I know how I study best!
Hopefully this gives you some ideas