Summary: No system wide setting has worked for me so far. You can open about:config in Firefox, search for "middle" and set to false as much as you can find there. In VS code you can search for "editor.selectionClipboard" and set it to false.
A dodgy mouse keeps middle clicking when the scroll wheel is used. This lead to a flurry of new tabs in Firefox and text all over the place in VS Code.
See: https://askubuntu.com/questions/1419274/middle-click-paste-disable for the VS Code setting.