External display flickers when connected to MacBook via USB-C

I’m using a MacBook Pro M4 with an external 4K monitor connected via a USB-C port. The screen flickers randomly every few minutes, and sometimes goes black for a second.

I’ve tried different cables and ports, but the problem persists. However, this monitor works fine when connected to my Windows laptop. Is there a solution?

Thank you.

try to Lock refresh rate and turn off variable refresh

System Settings → Displays → select the external monitor.