There was a program called CosmoSynergy in 1996 that lets you share a mouse between computers.
Barrier (a FOSS fork of Synergy) and Synergy are the only solutions that work across all 3 major platforms (macOS, Windows and Linux/X11)
Unfortunately they're buggy as hell, feature incomplete (no drag and drop), and ipadOS and anything Wayland based is unsupported. You also can't control macOS input unless the user manually grants permission (after installation) and on Windows there are still issues with privileged screens by default.
Imho the best commercial cross-platform (Windows and macOS only) tool for the job is Sharemouse, which has a bunch of value add features like multi-machine lock and unlock.