USB Keyboard works with dock or switching hub, but not with both

The USB switcher violated a very basic USB specification by using USB-A ports as inputs, it's nearly certain that they broke the spec elsewhere. It's not working correctly likely because they did not follow the specifications required of them. The USB-A to USB-A cables that came with the USB switch are a potential fire hazard if someone were to use them with anything other than the USB switch they came with. In the product description they warn the device can interfere with 2.4 GHz Wi-Fi and Bluetooth, another sign of poor design. This switch is broken, send it back for a refund if you can. Do not get another switch like it because that will be just as broken. The design is broken.

Depending on how you plugged things in it is possible you damaged your computer or hub using that cable that came with the switch, the cable with USB-A on both ends. That cable will possibly short circuit the power supplied by USB ports. Please stop experimenting with it. Throw it away or send it back.

The USB spec requires that ports that connect to a host need to be USB-B/female, USB-C/female, a captive cable with a male USB-A or USB-C, or a proprietary connector. It's rare to see a proprietary connector on USB devices any more but they were common on cell phones and other portable electronics before USB-C, usually some flimsy flat and wide connector with spring clips to hold it in place. Device ports should be female USB-A or USB-C, but violating this spec would be unusual since anything else would make it difficult to plug in devices.