This can be done is multiple ways. There’s a simple hardware device called the KVM switch that is helpful when your computers aren’t connected over a network. Each of these machines have separate monitors but they share the same wireless keyboard and mouse - thus the desk looks less cluttered and I can quickly switch between the two computers. My work setup is something like this – I have two desktop computers, each running Windows, and they are both connected over LAN.