Imposter syndrome is not something that just goes away magically. People often feel it throughout their entire careers. Also right now everyone is under additional stress, so I wouldn't be surprised if this is exacerbated.
Also, you may want to get checked for ADD/ADHD if you find you can fixate on things, but have trouble focusing on broader tasks.
You're a couple years into developing and feel like an imposter? Welcome to the club!
Literally every programmer I know has been wracked by doubts and existential dread over their skills. I've mentored a lot of interns and I always stress how impostor syndrome is normal, everyone gets it, including everyone above them in their teams.
My history is more of the "programming wunderkid", been programming since I was 13 and (like many on this site) find reading HN and programming news relaxing and recreational. I say all of this to highlight the fact that I got impostor syndrome. It was particularly bad the first few years. Once you realize everyone feels this way it's liberating. In fact you can even use impostor syndrome for good; either by motivating your learning or by empathizing with others.
I'm constantly learning and growing, which means I still feel like an impostor in these new areas. I'm the Kubernetes expert for multiple startup and government projects, but I still feel like a beginner in out of his depth.
The way I see it, you have two options. You push your comfort zone, and get comfortable with being uncomfortable, or you stagnate. You either become a constant learner who always has a niggling impostor syndrome, or your knowledge becomes static.
Be kinder to yourself, and at the same time try to design a plan that motivates you to learn more.
Usually, if you have impostor syndrome, a good cure is to learn something that is unique in your environment and makes you feel valuable. Or to build something on your own and see it finished and working.
I think you might have pinned it here. It may be that you are just fine as a developer but that you have burn out or some other mental health issue honestly. I don't mean that as a negative. I was burned out very badly a few years back and I felt exactly like you describe. It led to anxiety, depression, a lack of motivation, pain... nearly a mental breakdown.
I had been on a bit of anxiety medication for a while. I had a near breakdown (some would say a total breakdown). My doctor literally said "You need to go see a therapist. I mean it. You can either go on your own or I am locking you into the trunk of my car and taking you and you won't be let out until you talk to someone." (So, my doctor threatened to kidnap me, and thank goodness!) So I went and talk to a therapist. And talked. And talked so more. For months, then years. It has changed my life for the better. I am a better developer. I work better. I am a better husband and father. I FEEL better.
I really can't recommend highly enough that you take a look into your mental health. It will help a lot. So what now? Talk to a professional.
Also, you may want to get checked for ADD/ADHD if you find you can fixate on things, but have trouble focusing on broader tasks.