The
whole point of The Three Musketeers is that they are men out of their time, in an end-of-epoch story, surely.
Nobody drinks and carouses like they do, nobody has their sense of chivalry, artistry and old-fashioned justice. The world has lost its colour, its joy and its sense of fairness, and they are loyal to an institution which is itself corrupted and whose time is clearly ending. And so they are lost: they have no cause and they are slowly destroying themselves.
This is why they are portrayed as musketeers who think muskets (representing callous modernity) are clumsy and uncouth. It underscores that the three don't even feel they really fit with the rest of the musketeers. They know muskets have their place. It's just not with them. So there's no reason to explain them away logically. It's a literary device.
The second point is that D'Artagnan is there to remind them of who they were and could be again. D'Artagnan is the hero of the story because he has not been corrupted by life experience.
The third layer is he's also a proxy for the reader who wishes they were there. He is there to get life lessons on the reader's behalf: that stories don't tell the whole truth, that people begin to confuse themselves with their own personal mythologies, that fame isn't reality, that there are risks in meeting your heroes, that adults will let you down, that no institution is better than its people, etc.
This trope has been parodied in various ways since, not least I think in the form of "person who confuses actors for the people they play and convinces them they know as much about the job as the characters they play". Which has itself been parodied in Three Amigos! and also in Galaxy Quest.
And the trope of guns being impersonal compared to swords and knives turns up everywhere.