Hello there CodeSolve,
We understand you're trying to use the same keyboard and mouse for two separate computers on separate displays. Let's take a closer look as we do our best to provide some additional insight.
To get started, if you're using a USB mouse and keyboard, you can use a "KVM Switch", or "USB Switch". This lets you connect both computers to the switch, and then the shared mouse and keyboard as well. Then you can switch between controlling either computer using the buttons on the switch. While Apple does not make one directly, there's many products available that you should be able to find using those search terms.
This can also work with a Bluetooth mouse or keyboard, assuming it has a USB dongle that you can connect directly. If not, then you wouldn't be able to use it for this setup.
We hope this helps get you pointed in the right direction.
Take care.