I could use some honest advice from experienced programmers and engineers.
I'm almost at the two year mark as a developer. On paper I might look like a passable Junior Dev, but if you sat me down and asked me about algorithms or anything else I did to get my job in the first place I would be clueless. I can solve problems and always get my work done, but I don't even know the language/framework I use daily well enough to explain what's going on, I can just do things. I don't think I have imposter syndrome, I think I really might have let any skill I had atrophy.
I used to enjoy programming as a hobby in my spare time, but in two years I've opened the IDE on my personal machine no more than twice. People talk about all the side projects they have, but I have none. I feel too stressed out from the job to do any programming outside of work, even though I love it. I feel like I can't level up from a Junior to Senior because I either don't have the headspace or the will to do so. It doesn't help that the job I've had has taught me very little and my dev team has been a shitshow from the beginning.
At the moment I have an offer on the table to do a job that isn't engineering (but still tech) and it surprisingly pays more. Part of me thinks I should take that job, rediscover my passion in my spare time and build my skills, but I fear I might go down this route and never be able to come back to engineering. Not that I'm sure I want to.
It might sound defeatist but I don't think I'll ever be a top 5% or even 25% engineer. I could be average with a lot of work, but not great. I could potentially be great in the new field I'm being recruited for, but that's also hard to say without being in the job.
I know that some people just aren't cut out for being engineers. Maybe I have the aptitude but not the mentality to do this for 30+ years. I want to know if that's what it sounds like to people who've seen that before. If you were in my position, would you walk away and just be a hobbyist programmer or stick it out and hope to be a mediocre engineer one day?
From your description, my view is limited, there is no correct solution. Any choice is viable and fine, and any decision you make will be due to the reasons you chose with.
You didn't disclose what the alternative opportunity and field is, and also not your view on the field and you in it. So it's difficult to assess and put into relation.
You didn't disclose what you did before work, but two years is not that much experience for an engineer. Especially if it is not a particularly nourishing environment. You gain such expertise through experience and exposure over time. Depending on the project and environment it's also not enough to fully understand and intuitively know a big project.
At my workplace we separate role from [personal] development level. As a developer one's role may be developer or lead developer. The development stages are Trainee, Junior, Professional, Senior. If you can work on tasks mostly self-reliant (asking and collaborating is still open of course; knowing when to ask is a skill too) and can put tasks and work into context, you are a Professional. A Senior can support and guide the team. It is perfectly fine to settle for Professional.
Not being exceptional is not a good reason to quit. If you work and bring value, that's still value. Don't decide whether you are valuable or good enough for others. (This leaves out the question of what it means for yourself of course. Tackle those questions individually.)
You say you get your work done. Continuing to do that at a Professional Developer rather than Senior level is fine. You still bring value.
I really can't answer that specifically.
You said your team environment is not the best. I assume you don't do retrospectives or personal feedback. Is feedback something you could ask [of some of] your team members, lead, or seniors? (Take care not to poison your question for open feedback with your negative assumptions of yourself and your work.)
Where would you like to be? Separating what you think is expected of you from your expectation and view of yourself and from what you enjoyed and where you think you would feel comfortable settling, how would you lay those out?
Have you considered switching project or employer? You have only seen and experienced that place. A different work environment could be very different - even in the same field.