My question is, is it my fault that I was overlooked, undervalued and underpaid for so long?
There's no way to know without a lot more details, but "fault" isn't something that should worry you anyway.
Every company has a unique culture. Some companies value quiet, steady work. Other companies value loud cowboys. In some companies you can grow to more senior roles naturally and easily. In some companies, you can campaign actively for a promotion when a new job opens up and be considered. In other companies, once a newbie always a newbie. Knowing what is important within your company and maximizing those attributes only comes with time and experience. Perhaps you were too young and too new to learn that.
And sometimes the only way to get paid market value is to actually put yourself on the market.
My first professional job was a good one in many aspects. I learned a lot, had a good mentor, was well-respected and enjoyed the work. But the pay was sub-par during high-inflation times and it was clear to me that this company didn't value the things that I was particularly good at. It wasn't their fault, they were an older stable company in a low-margin, lower-tech industry (it was a supermarket chain and I worked in IT), and I was particularly strong in learning and adapting newer technologies. I made a decision that was difficult for me at the time, and found a new job with a significant salary increase. Like you, I also turned down a signficantsignificant offer to stay. I never looked back.
Over the years, I've learned that it pays to keep an eye on the market. Even if you are happy in your job, learn what skills companies are looking for. And learn what companies are willing to pay for. That can help guide your actions in the future.
Sometimes you'll decide that you need to update your skills on your own. Sometimes you'll decide that you can get what you need within your own company by being a little louder or more proactive. Sometimes you'll decide that you need to move on and find a new job - perhaps in a different sector.