You use two monitors on your Mac and the macOS Dock jumps back and forth? We explain briefly how Apple has thought about the functionality.
In the system preferences you can define which monitor should be the first and the second monitor. For example, the login window is always displayed on the first monitor. If you wondered why the dock always jumps back and forth between two monitors when you are working with two monitors, this is the way it is supposed to work.
macOS Big Sur: Two monitors, one dock.
Namely, the dock switches to the current screen whenever you touch the bottom wheel with your mouse (assuming the dock is down). Then the dock comes after the mouse, so to speak. Most of the time this works quite well. Sometimes you have to touch the edge several times to make it work. Even if you remote control the mouse pointer with an app on the iPhone, this function sometimes does not work immediately.
By default, the dock jumping is triggered by touching the edge of the screen where the dock is currently located on the other monitor. Now you don’t have to wonder why the dock always follows you secretly.