Short answer: DisplayLink and other USB display adapters add screens through software, and those screens often come back a few seconds after the Mac wakes. In that gap the Dock settles on another screen. Set the right main display, keep DisplayLink Manager current, and lock the Dock to one display.
A DisplayLink dock or adapter drives monitors over USB with the DisplayLink Manager app, not through the Mac's own graphics outputs. That is how base M-series MacBooks run more external screens than Apple supports natively. It also means:
None of the fixes above stops the Dock moving when the pointer pushes against another screen's edge. Still Dock's One display lock keeps the Dock on the screen you choose, DisplayLink screens included, in both the direct download and the Mac App Store version (Pro).
USB screens often run at a different scaling from the laptop panel, so the same Dock looks a different size on each. See Dock resizes on an external monitor.
Partly. The Dock following the pointer is standard macOS. DisplayLink's later wake makes the after-sleep jump more common.
With the lid shut the built-in screen is gone, so there is one fewer place for the Dock. On wake the external screens may still return one at a time.
It restarts the Dock on the main display. See what killall Dock does.