A big reason joystick drift is a thing is that current controller designs allow dirt, grime, and dust to get into the tiny space that connects the joystick and the controller. The joysticks on the DualSense have a small gap to allow for smooth motion and that gap is large enough that smaller dust particles can get into the joystick assembly. If dust, crumbs, or something similar gets in the sensor component called the potentiometer, it could cause the controller to register stick movement when none is taking place.
Unfortunately, this means there really isn’t a guaranteed way to prevent the issue short of never using the joysticks on your controller. Though most people think debris is the most common cause of drift, that’s not necessarily the case. iFixit investigated the phenomenon and found that the vast majority of drift issues originate from mechanical problems like wear and tear, which naturally happens over time when the controller is used. The team also detailed a potential permanent fix for the issue, giving gamers hope for a less frustrating future.
This is similar to an issue that plagued Apple’s butterfly keyboard design. The gap, though small, was large enough that dust particles could get wedged between the keys, causing some either to become stuck or to register a double press even if the user only pressed the keys once. The two issues are more or less one and the same — though, in the case of the DualSense controller, instead of involving keys getting stuck or double pressing, you have to deal with phantom joystick movements.