To answer your question: You should probably get checked for ADHD. I don't say that to stigmatise, but issues focusing should really be treated by a mental health professional and not a bunch of internet nerds on a forum.
That being said: focus on solving a particular problem to completion is more about having discipline than having motivation, do a little every day without fail and you will succeed, often the hardest part is to start.
As for more personal advice (as a person who has ADHD, this will be like the blind leading the blind unfortunately), but it helps me, and it comes in two forms.
First form (easy to accomplish, shallow focus)
1) The night before going to bed, think about what you want to do first thing in the morning.
It helps to keep a task list, but set a single (even easy) goal for the next morning.
That morning goal can be anything such as closing a small ticket or reading a chapter of that computer book you've been avoiding.
2) In the morning, resist the urge to touch your phone, do not check email. Your day has not started until you complete that task.
Why? Because the world does not exist to you yet. Thus: no distractions.
Quickly you realise your FOMO from social media can be tapered.
---
Second form (hard to accomplish, deep focus):
This one unfortunately requires rigor in your working habits, discipline and reading of the book "time management for systems administrators" by Tom Limmoncelli.
It applies to everyone, not just sysadmins, but sysadmins used to do the kind of ad-hoc work that makes focus impossible. The first chapter of the book is literally titled "How to find time to read this book".
But keeping a journal of what you want to accomplish each day and then being aggressive about what is actually possible is the essense of the book, it goes into much more detail and is much stronger than the notions behind bullet journalling than it sounds on the surface.