Short answer: the thin vertical line in your Dock is a resize handle, and you are catching it with the pointer without meaning to.
macOS gives you no way to undo that, and no way to type in the size you had. Below is why it happens, and the three ways to make it stop.
Look at your Dock and find the thin line separating your apps from the Downloads folder and Trash. That line is not decoration. Click and drag it up or down and every icon in the Dock rescales.
It sits at the bottom of the screen, in the same strip of pixels you cross whenever you reach for the Dock, aim at a window edge, or grab a scrollbar. There is no click-and-hold delay, no confirmation. A single stray drag is enough.
This is the part that makes it more than a minor annoyance. macOS does not store the size you had before, and it does not offer an undo. Your only way back is to drag the divider by hand until it looks right again.
The Dock size slider in System Settings has the same problem. It is a slider, not a number. There is no readout telling you that you were on 48 and are now on 61, so you cannot return to a value you never knew.
A taller Dock takes vertical space away from everything above it. macOS shrinks the usable desktop area, and windows that were sized to fit get pushed and resized to match.
So one accidental brush of the divider does not just change your icons. It rearranges a window layout you spent time building. On a carefully arranged desktop that is ten minutes of dragging things back, and there is no undo for that either.
If your Dock changes when you have not touched the divider, one of these is usually why:
System Settings, then Desktop & Dock, then Position on screen. A side Dock keeps the divider out of the path your pointer takes along the bottom of the screen, so you catch it far less often.
It does not make the Dock unresizable. It just moves the trap somewhere you walk less.
macOS has a hidden setting that makes the Dock refuse to resize. It is not in System Settings, but it works. Open Terminal and run:
defaults write com.apple.dock size-immutable -bool true; killall Dock
Your Dock will vanish and reappear, which is the killall Dock part doing its job. The setting does nothing until the Dock restarts. From then on the divider will not budge.
To undo it, run the same line with false:
defaults write com.apple.dock size-immutable -bool false; killall Dock
Two things to know. While the lock is on, the Dock size slider in System Settings stops working, and macOS says the setting has been configured by a profile, with nothing to indicate that it was you. And the lock holds whatever size you were on when you ran it, so get the size right first.
There are three more of these settings, covering position, contents and auto-hide. We list all four in the Dock settings Apple never gave you a switch for.
The Terminal route works and costs nothing. What it does not do is remember the Dock you had before you locked it, or let you change your mind without going back to Terminal.
That is what we built Still Dock, an app that locks the Mac Dock, for. It is the same underlying settings behind four switches in your menu bar. Flip the size lock and the divider stops responding. Flip it back and your Dock returns to exactly the size it was before you locked it, because the app recorded it. Delete the app and everything reverts.
You can try the behaviour in your browser on the home page, no download required.
Using more than one screen? The Dock also jumps between them, which is a separate problem with its own fixes: how to keep the Mac Dock on one screen.
No. Size and contents are separate settings. With only the size locked you can still add, remove and rearrange apps, though remember that adding an app to a full Dock is itself a reason icons rescale.
Yes. It is a stored preference, not a temporary state, so it holds across restarts and logins until you turn it off.
Yes. These settings have worked for many years and still work on current macOS. We test on macOS 26.
There is no correct answer, but decide before you lock it. Set the Dock how you like it in System Settings first, then apply the lock, because the lock freezes whatever is current.