I personally don't think it's something "wrong" with you, most probably there's something wrong with your process.

I have the same issues, and I think you speak out for lots of people, motivation is a very limited resource and when it's not used properly, you end up in this state.

What worked for me best is to tackle your tasks with the notion that you have limited resources in mind and that you're just human.

Some tips that you might find useful, that certainly work very well for me:

1- Declutter your workspace, clean your whole house, having small things here and there lying around affects my thought process.

2- Declutter your brain, Throw away ideas that might be nice, but are not possible to work on right now cause they'll take tons of time and money, write those ideas down somewhere for later use, if ever.

3- Declutter your life, make sure you don't have lingering problems that can be fixed now, your brain will fatigue out when you have a lot in your stack, fix that leaking toilet, talk to your spouse about the issue you've been always having with them, tell your friend you can't help them with that thing they needed, empty out as much as you can, and work on the low hanging fruits first.

4- When it comes to tasks, spend as much time as you can afford planning it ahead first, break things down into small actionable tasks that will take a few minutes or hours to resolve, avoid homogeneous tasks like "Implement backend", "Fix the known bugs", "Release next version", etc... instead, have very concrete minimal tasks like "Fix bug #21", "Create Users profile database schema", "Convert header image to SVG", etc...

5- Timebox things when planning, say you'll spend only 1 hour today working on this issue, if you can't, then take it again in the next planning and break it down further and give it an appropriate time slot

6- Getting great ideas while working is almost like thought cancer, don't start on them, write them down and continue to do what you are doing

7- Don't start new tasks before the assigned ones are actually done

8- Don't reward or punish yourself, rewards tend to make me very narrow minded, and punishment takes the fun out of things, ask yourself why you are doing what you're doing and why you have to do it, write that down and keep it as a reminder in your workspace.

9- Talk to others, let people know what you're doing, and when it's expected to be done, this keeps me at least from getting lazy as there's expectations form others to see what i've done

10- Listen to different music, I noticed that once I changed my playlist that was on repeat, I was a completely new person, play a podcast instead, or listen to radio or channels that you have no control over.

11- Kill the projects that are taking too long and deep inside you you know that you'll never manage to finish, find smaller ones that are realistic.

12- Always remember that nothing has to be perfect, it's better to have something out there, most of the time no one even notices what you think is a crisis.

13- Ask yourself everyday, is this what I want to be doing?, am I happy?, should I continue? if the answer is truly a big yes from your heart, then go on, if not, try to find other things that might be more fun for you.

Tis is what works for me, your results may vary, but what matters is that you have to be relatively happy doing what you do!, if you think you're suffering from ADHD, I would say it's best to visit a therapist, it'll clear out lots of things, don't feel bad spending money on yourself a bit, it's worth it. also if it's your kind of thing, find a mentor :) keep up the good work and never give up!