KVM switches are great to connect your peripherals to different computers on a click of a button.
Do not use the dedicated USB keyboard port
Do not use the dedicated USB mouse port
If your KVM switch has a dedicated USB port for a keyboard:
If your KVM switch has a dedicated USB port for a mouse:
Do not plug in your Apple device there, otherwise unforeseen things may happen.
On the console section use a generic USB port to connect your Apple device.

Example ports of a Tripp Lite: 2-Port DisplayPort KVM Switch
The issue is not within the KVM switch. But the Apple device may send USB HID data which is not what the KVM switch expects and described in the HID descriptor.