You need to check your power options in control panel. You will find that there are two options one for battery and one for plugged in.
You need to change your power plan setting to match those to plugged in. Also check advanced power settings i.e if your hard disk is idle or other device is idle your laptop will be shutting down to conserve power to save you from suffering a total lose of power in an instance which could cause you a bigger problem damaging windows and other software files.
Myself I leave everything turned off in my power options as use it very little on battery you should however allow it to turn your laptop off when the battery reaches 10% charge this will make your battery last longer in the long run don't allow...