I had to do this same repair on my granddaughter's Switch. The little retainer called a buckle lock is made of plastic and rubs against the metal rails, which means it is guaranteed to eventually wear out.
Fortunately for us, iFixit sells replacement buckle locks, only these are made of metal rather than plastic, meaning it will never wear out again like the old ones.
Nintendo Switch Joy-Con Replacement Metal Buckle Locks
The replacement procedure isn't too bad, but you do have to take apart the Joy-Con.
Joy-Con Buckle Lock Replacement - iFixit Repair Guide
One note that I ran into: the two buckle locks on the left and right controllers are not the same! Make sure you match up the left buckle lock with the left controller and vice versa. I got it wrong and was dismayed when my replacements didn't work until I read up on it and found out I had the sides reversed. Went back and did the whole procedure all over again, swapping the sides and after that everything worked perfectly. So watch which side is which; don't be me. :)
crwdns2934105:0crwdne2934105:0
crwdns2934113:0crwdne2934113:0
crwdns2915270:0crwdne2915270:0
crwdns2889612:0crwdne2889612:0
3