I've been WFH so I have my work laptop and personal MBP side by side. How I've handled this with the trackpad is to connect wirelessly to the Mac, then plug the trackpad in to the work computer when I want to use it there. It seems to work pretty well, at least I haven't had to make much extra effort when switching.
I'm not sure if this will also work for the keyboard but I would expect it to. And I would hope there are better solutions, but unfortunately there might not be.