I was sincerely frustrated as to how flaky it all seems too.
I have a monitor that's 4K/60 if I directly cable to it, but often only comes up at 30Hz (or 4:2:2 colour mode 60Hz) if I use a KVM. Yes, the KVMs were sold as "4k/60 support" and I've tried two different ones (one HDMI, one DP). One machine works fine, because it's a sucky pre-Cambrian laptop dock that isn't even TRYING for 4K, and the failing one is a desktop with a GTX1080.
What's interesting is that it seems like it only happens in Windows. I experimented with a FreeBSD install, and the drivers there reliably hit 4K/60 even with the DisplayPort KVM in the way.
I suspect the drivers must have different strategies to probe the capabilities of the device and cables, and the Windows drivers interpret them more conservatively.
So I ended up using the KVM as a $100+ USB switch and just toggling the inputs with the monitor's own buttons. (I gather there's software that could do automatic input switching via DCC configuration channels, but one machine is corporate-managed so I can't just stuff random software on it)