1. Run the laptop only using the charger, thus remove battery and see if it restarts. If you find the battery is the issue, replacing it since its 2 years old is not a completely bad idea, however you feel your battery is still in reasonably good condition, navigate to device manager and expand "battery" area, and delete microsoft battery control method. Now reattach battery and boot up as normal and windows will reinstall the deleted drivers thus hopefully kicking the battery into normal operational mode.
2. If still does, try another charger.
3. If you feel the battery and charger are fine, the try booting up in safe mode and see if it still restarts. Obviously at this point if its fine in safe mode, try updating antivirus and install malwarebytes and run full scan, if any infections are found remove or quarantine and restarts the laptop in normal boot up mode and see how it performs.
4. Ram is another area to check, if your laptop has one stick of ram, move the ram to the next slot and power on to test in normal boot up mode. If there are now issues, your ram slot may be failing, at this point check for dust etc. If in the 2nd slot then we can assume the ram itself is faulty from here you need procure new ram to really see if the this area (ram and ram slots) are problematic.
If you have 2 sticks of ram, remove in this case the ram in slot 2, and then turn on the laptop and test. If the laptop is fine, we then need ascertain if ram slot 2 is faulty or the ram that was in slot 2, to solve this issue move the ram from that was in slot 1 which just tested and slot it into ram slot 2. Now turn on the laptop and test, if the computer works fine we now know that ram slot 2 is working and thus leads to us believe that ram 2 is faulty.