Turning/Looking in Minecraft is tied to your mouse movement.
Basically, when you move your mouse, your avatar will look around. When you stop moving your mouse; so will your avatar.
Normally, while in game (and not interacting with any UI) your "cursor" will be pinned to the center of the screen, to allow for unlimited movement. The only reason that this isn't the case, is if your game is not the primary focus. This could be for many reasons, such as system notifications, backgrounds apps, or even a bug.
Every time this happens, you should be able to ensure that Minecraft is the main window that has focus, by using Alt+Tab to change which application is your main window.