How to make my peripherals connected through monitor be detected by laptop

The USB on the monitor goes down the USB cable, not down the HDMI. HDMI cannot tell a PC to connect specific ports up.

If you want to swap USB between two machines then you will need some kind of USB switching device like this one that has two ports to connect to two different computers and four ports to connect your peripherals.