Because in D&D there are no lawless frontier towns which need protection from bandits.
Sure there are, but this is true of frontier towns from many cultures across the world. It's not a link to western frontier towns.
There are no adventurers-for-hire riding in with their weapons proudly displayed.
Again, true of many cultures around the world.
Really? The old west is all the wilderness the world has ever had?
The characters never have to create their own justice, because the local law officers take care of everything.
Not legally, and not something even remotely limited to western frontier towns.
Nobody ever rides off into the sunset.
I can't recall that ever happening in a game I played or module that I've read. If you simply mean leaving after you've fixed the local problem, it's again something that applies worldwide and not limited to western frontier towns.
And the sudden influx of gold being compared to the Alaskan gold rush was for illustrative purposes only, and not meant to parallel the Western Frontier at all.
This is correct. I quoted the passage that said where the gold comes from. It didn't come from adventurers going out and mining it, or NPCs for that matter.
Also Gygax never read any westerns, he never read Howard - who never wrote any westerns - and he wasn't a libertarian steeped in 1940s and 1950s nostalgia.
No clue. I don't know how much any particular thing influenced Gygax. And neither do you. I do know that he flat out said that the influx of money in D&D was due to successful adventurers, and did not say it was due to wild west like mining operations.
Go look in the mirror. The thing in the middle of your face is your nose.
Nothing you listed is exclusive to western frontier towns and the game itself is written to be roughly medieval European, not American wild west.
If you're going to claim lots of wild west influence, you need to be able to show proof of that, not vague suppositions that more easily apply to other cultures around the world.