For anyone else wondering, I was able to fix this by using the control stick calibration tool in the Nintendo Switch settings menu. I got no more drift after doing so.
UPDATE: This fix only worked temporarily. I’ve since ordered a replacement analog stick from the ifixit shop, and will be replacing it soon.
UPDATE 2: Took me far longer to get around to replacing the sticks than I expected, but I finally got it done! Part of the reason it took so long is that desoldering the original stick was a nightmare with my normal soldering iron, and I gave up after my initial attempt. Within the last few months I decided that for this and other projects it was worth investing in a Hakko desoldering gun. If you intend to solder and desolder more than just occasionally, I can’t recommend this tool enough. I spent hours trying to desolder the analog stick, and failed. The desoldering gun got it done in minutes. That said, it’s an expensive tool, so if you don’t make a habit of soldering, you’re better off taking the controller and the part to a repair shop and paying them to do it.
UPDATE 3: I am trying to recalibrate the sticks after the replacement, but while they are working, they cannot reach far enough in certain directions to register with the calibration tool. I am looking into why this is and how to fix it and will update when I have an answer.