A good therapist can help you figure this out, and give you better coping strategies.
It took me years to figure it out but I struggled to be consistently productive because of a mix of untreated insomnia, adhd and bipolar 2. What made the difference for me was really analyzing my symptoms, seeking out goal/skills-oriented therapist (a PsyD not a MFT), and not giving up after the first psych med or two didn't work.
I've seen people who really lack the awareness to know that they're underperforming, or the willpower to try to fix it and get help. Thankfully you don't seem to be one of those people.
Also, I'm going to echo everyone and say that you should probably get screened for ADHD. With ADHD it's very common for an inability to focus -> frustration that you can't get things done as fast as you should be -> depression/anxiety.
> There are phases where I work with high motivation but it fades easily. I have found I work on my side things with interest but I am not a completer. I complete around 80% of things and then leave them.
Probably describes most of HN so don't feel too bad about that haha.