I don't know the cause of the problem, but what steps are you taking to ensure you have the camera level? Are you using a bubble level, or have you switched on the camera's virtual horizon feature, which will give you a line to check the composition?
Edit: I see Marty beat me to it with a much more comprehensive answer
Edit2: It seems the D5100 doesn't have the virtual horizon feature... Apologies!