Laptop switches off automatically

Let me mention everything in detail. My laptop Compaq 621 used to work well until it's battery expired.. I replaced battery and it was working well again but when I installed Windows 10 ,it started getting off automatically while loading windows, I thought may this Is the problem with Windows so I changed to Windows 7.. but still had the same problem. While loading windows it used to get off. So I used to keep it in sleep mode so that I don't face this problem again. But the problem got worse. Now it completely failed to load windows and used to get off while loading windows. Then I sanitized whole disk and loaded windows again but the problem is still there.. now I switched to Ubuntu Linux.. some how things got better it works but still gets off automatically anytime..I don't know what the problem is. Please help
 
Back