Unfortunately that behavior is a common pain point when hopping between Apple devices. The Magic Keyboard and Magic Mouse automatically pair with the last device they were connected to, and they tend to hold onto that connection stubbornly—even if you plug them into another device via USB.
The trick is that you don’t have to unpair them from the iPad first, but you do need to override the connection to your Mac. Give the following a try:
For the Magic Keyboard:
- Connect it to your Mac with a Lightning to USB cable (directly, not through a hub if possible).
- Wait about 10 seconds, then press a few keys.
- Go to System Settings > Bluetooth, and your Mac should now recognize it and auto-pair with it.
- Once it's connected, you can unplug the cable — the pairing should persist wirelessly.
For the Magic Mouse:
- Same as with the keyboard, plug it in via Lightning to USB, wait a few seconds.
- Wiggle it a bit, or click once or twice.
- Check System Settings > Bluetooth. The mouse should show up and be paired.
- Once it's paired, unplug it and test wireless functionality.