If the Screen Rotation lock is set to OFF, then SOME apps will detect the orientation of your iPhone and rotate automatically. The Messages app has that capability and so does the Photos app etc.
You can set the Screen Rotation lock to ON, so that the apps do not rotate with the orientation of the iPhone. Please read below about this feature:
Lock or unlock the screen orientation
You can lock the screen orientation so that it doesn’t change when you rotate iPhone.
Open Control Center, then tap
If the button is highlighted in White, then it is engaged and Screen Rotation Lock is set to ON.
Axel F.