You do not know it for a fact, as you are, I'm afraid, incorrect. Just because two devices have similar problems doesn't mean that those problems have the same causes - any more than having a fever means you can
only have the flu, and not some other viral infection.
Sticks are always and will always be at least partially mechanical. Moving parts can fail. Failures will cause false inputs. False inputs will cause drift. That doesn't mean the failures will be always the same, or equally likely. Joy-con drift is much more common than drift in other devices, because the device is very thin. That's not controversial, it's pretty obvious once you've disassembled one.
Most sticks nowadays use potentiometers. They're accurate, cheap, and very flexible. But they're very vulnerable to dust. Worse than that, they
create dust - there is a little graphite nub that moves along a strip as you move your stick. The graphite wears out, because all mechanical parts wear out - graphite is basically "pencil lead" and it creates little dust fragments.
This is the stick in the Dual Sense. The two dark circles in the green square are the strips of the potentiometers. You'll notice that the strips are on the
side of the assembly, which is a cube. Now compare to the Switch stick.
Flat as a pancake, for obvious reasons. The black square has the potentiometer strips facing up, toward the controller itself. That means that as the graphite wears down the dust settles
directly onto the potentiometer strips.
Worse, because the Joy-Con is so thin, when you put pressure on the stick, you're squeezing it from both sides. The forces the graphite to make stronger contact, which wears it out faster. The sticks are rated for a certain number of stick rotations over the course of their lifetime before the graphite is supposed to give up the ghost. It's highly likely that the additional back pressure is why the fail so much faster than they are rated for.
Ironically, the easiest fix is to
increase that pressure, forcing the graphite to make stronger contact with the strip, and then recalibrating. It was called a "permanent" fix for drift, but it actually increases the rate at which the graphite wears out (though if it makes the controller usable in the interim, probably worth it).
So, yes, the thin size of the Joy-Con absolutely contributes to drift. All three console manufacturers use off-the-shelf sticks, and for cost reasons I imagine they'll continue to. It's unlikely that Nintendo can switch to the larger Dual Sense sized assembly, at even a modestly larger controller. So the better solution is an optical or hall effect stick. No clue how likely that is from a cost perspective