Why does the dock appear on the left when my screen is locked?

This should not happen under normal circumstances, as per GNOME's security policy, whenever you enter the lock screen all the extensions get disabled automatically until you get back in, and then the extensions get re-enabled. Somehow it's failing here for the Ubuntu Dock extension (gnome-shell-extension-ubuntu-dock) and so it's a bug.

Note: Bug reports are off-topic here.

As a temporary workaround either restart (or relogin to) your system or restart GNOME shell by pressing Alt+f2, then typing r and pressing Enter.