The really strange thing was that Windows showed the login screen on my main monitor and the problem didn't happen until after I logged in, when the secondary monitor would suddenly become my primary. This symptom provided the key to the problem. After you log in, the nVidia Control Panel overrides your Windows display settings, so you must make sure that everything is set the way you want in the nVidia Control Pane.
To solve the problem, I did this:
- Opened nVidia Control Panel > Display > Set up multiple displays.
- Dragged the displays to the proper location.
- Checked all of the displays.
- Right-clicked on the desired primary monitor.
- Selected "Make this the Windows primary display."
- Clicked Apply in the bottom right.