Why does Samsung GS4 pattern lock sometimes change to side-by-side layout? I have the SGS4 SGH-M919, Android 4.2.2,  WickedV8 ROM. 

Normally my lock screen looks like this:



Once in a while, my lock screen unexpectedly changes to this side-by-side arrangement:



I have not done anything to cause this change, and I am unable to find a way to change it back to normal other than rebooting the phone.
The "pencil" icon does not cause anything to move.  If I try long enough, a message will appear that says something like "your security settings prevent changes to the lock screen".  I can still unlock the phone, but the small pattern is less convenient.

I do not find anything in Settings that would control the layout of the lock screen. 
Can anyone explain why this changes and how I could prevent it or change it back to normal without a reboot?
That seems like it is a bug in the custom ROM you are using. Many custom ROMs (or Xposed modules) that add a rotate lock screen function may have that bug. If it is disabled, and the bug occurs, there only ways to reverse it are to either restart com.android.systemui or to enable auto-rotation of the lock screen and then turn the phone into landscape mode, then back to portrait (it may take several attempts; it may not fix itself at all for both methods).

Alternatively, if you do not have that option, you can install Xposed Installer and either the module Wanam Xposed for TouchWiz or Gravitybox JB / KK for AOSP. To change lockscreen rotation settings.

Personally, I recommend adding a shortcut to your homescreen to kill systemui. You can do this by installing an app like ROM Toolbox Lite. Create a homescreen shortcut from ROM Toolbox (or whichever script app you installed) and make it a script. In the script, issue the command pkill com.android.systemui. Make sure that you have root privileges and to (if necessary) tell the app to run it with root.

BUG: There is an existing bug where, if YouTube is running in the background, may inadvertently cause lockscreen rotation. This can be solved by killing the background process YouTube.