For me it was the work itself that also was the problem. I love engineering. That's what's so tragic about it. I love engineering as a discipline or academic subject. But put me in front of a computer and ask me to do the same type of work for 40+ hours a week? I break.
Don't be afraid to seek outside help or to consider wildly different career options. If you can do the work just fine, maybe you should look into finding a way to exercise your skills as an independent consultant. Don't work for anyone. Just take on work and do it.
But yeah, I totally get just wandering off. At this last job, I initially quit after three days. My partner and our real need for the money at the time was enough motivation for me to give it another go, and the company was willing to work with me. But in my heart, I knew where this was headed from day one.
After about 8 months, I reached a breaking point and requested to go on unpaid leave. I took two months, worked with a therapist in the meantime, and got on some medication. I spent my time pouring myself into my hobbies, hoping to reset the burnout.
Last week I went back, and I quit after three days. When I finally got back into the work for real, nothing had changed. It emotionally felt exactly the same. (And that was enough to have me curled up into a ball, rocking myself though a panic attack at my desk.)
There might still be a way to make it work for me. Maybe on the right medication and therapy I could find a way to make it work.
But frankly, I just don't want to anymore. I'm tired of the pain. I've built up so much emotional scar tissue relating to office work. I'm just done.
I'm just going to do teaching now in whatever form I can. Maybe someday I find a way back to an engineering classroom. Maybe I just be a career tutor. Maybe I become a high school math teacher. I don't know. All I know is if I keep doing this to myself, I'm going to end up on a bridge somewhere. It's gotten that bad.