Putting your laptop to sleep and letting it run flat is one of the problems. You should be putting it into hibernation if you want to leave your laptop and then resume where you left off.
I'm not sure what you mean by it formatting itself as when a system is formatted, the drive is wiped clean and a new index record is created. It may be resetting itself or rebooting while you have programs open. Windows updates do sometimes require the pc to be rebooted and therefore resetting the system but nothing should be lost if you've saved your work. If the system is on an update schedule, then the reboot will happen then. If the system runs updates when in idle, then the reboot will happen then.
Save your log in information into your browser and then you won't need to log in again until a verification is done. Then, enable hibernation so that when you close your laptop, it saves it's current state and turns off and therefore will no longer use power and will not run out and even if it does, when it powers back on, it'll resume from the hibernated state.