When you take a picture, your D5300 can record the image orientation— whether you held the camera normally, creating a horizontally oriented image, or turned the camera on its side to shoot a vertically oriented photo.
During playback, the camera can then read the orientation data and automatically rotate the image so that it appears in the upright position. The image is also automatically rotated when you view it in Nikon ViewNX 2 and other photo programs that can interpret the data. If you disable rotation, vertically oriented pictures appear sideways.

Photographers use the term portrait orientation to refer to vertically oriented pictures and landscape orientation to refer to horizontally oriented pictures. The terms stem from the traditional way that people and places are captured in paintings and photographs—portraits, vertically; landscapes, horizontally.
Set up your rotation preferences by using the following two menu options:
Auto Image Rotation: This option, on the Setup menu, determines whether the orientation data is included in the picture file. The default setting is On.
Rotate Tall: Found on the Playback menu, this option controls whether the camera pays attention to the orientation data. This one is also enabled by default.
Regardless of these settings, your pictures aren't rotated during the instant-review period. Nor are movie files rotated.