I've just noticed that whilst shooting with my D5100 using M mode settings reset after each shot.
Say, the camera is on a tripod pointing to an object. I've balanced out the exposure to a 0, aperture set to F/8 (this doesn't change btw) and the shutter speed is set to 1/15. I take the picture (camera hasn't moved) and the exposure level and the shutter speed have changed to some random settings (+2 EV exposure and 1/250 shutter speed - it's different every time though).
I've searched everywhere, but couldn't find an option that would allow me to save/lock my current settings providing the the image in the view finder doesn't change.
This behavior is caused by automatic exposure bracketing.
I've had someone with a Nikon D5000 behaving the same way in manual mode, and it turns out that automatic exposure bracketing caused this problem. My Pentax K-5 behaves the same way if the drive mode is set to exposure bracketing in manual exposure mode.
If this does happen to you again, make sure that bracketing is not set and disable it if it is. You do not need to reset the camera to factory defaults.
I have a D5100 and I have not seen this happen. As Zak mentioned you may want to try a factory reset. Also are you using the latest firmware for the D5100? The only time I have ever seen anything reset is after the camera turns off, and even then the only thing I have seen reset going from Quick Response Mode for the remote to Single Shot mode. The settings themselves stay the same.
That is called "Exposure Bracketing", found under "Custom Settings" on the D5000. It makes the camera change the values so you can take 3 pictures: a properly exposed one, an over-exposed one, and an under-exposed one (not necessarily in that particular order).
This is for safer/faster/more efficient shooting for some situations where you run the risk of having under or over-exposed photographs.
You can disable this function so your exposure and aperture values stay locked. There's a similar option but for automatic ISO as well as White Balance.