Maybe trying disabling all overlays and see if that fixes anything (Mumble, Discord, Shadowplay). It could also be something weird going on with the windows game mode/xbox game bar.
I would try to also limit the amount of background applications running that could possibly affect tf2 performance.
Try running tf2/mouse software as an admin.
I had an unrelated issue with a different mouse and that was resolved by installing an earlier version of the driver so maybe that could help.
It could also be a hardware issue with Logitech mice. I'm not sure if Logitech programs have it but some mouse software has a built in sensor check to see how well your sensor is reading the surface. In general maybe some dust or something is messing with the sensor.
This is probably in no way the issue but a good check anyway - for some reason the game auto binds alt as a key that allows you to hold it down and walk with the mouse. I had a previous issue with my mouse because my alt key was getting stuck down so my mouse would randomly stop sometimes.
Another possible issue which is probably unlikely could be some weird electrical interference going on. It could be affecting the mouse signals. Even if its wired, the mouse might still have issues from interference unless it has one of these on it