This happened to my iPhone X several times now, I think it since updating to iOS 11.3, and the only fix I can do is to press both the volume down and side power button at the same time, then the screen will prompt you with option to turn off the phone or cancel. I pressed cancel and the lock screen turns back to portrait mode.
Apple - please fix this bug and release a new update. This is getting annoying.