Computer occasionally shutdown by itself without warning because of following reasons:
1. Heat related issue - Most computers today are designed to turn off automatically if any of its inner components overheat. Often, heat related issues occur when the computer is working hard, e.g. playing a graphically intense computer game.
2. Hardware related issues - Any failing hardware component in your computer could cause your computer to unexpectedly turn off without warning. If you have recently added any new hardware, remove it from the computer to make sure it is not the cause of the problem.
3. Computer virus - Your computer may be infected with a virus or other malware that is designed to shut down your computer upon certain conditions. If your computer seems to be turning off when executing a certain program at specific times of the day, it could be infected.