Well there is no way to know if it is a virus or malware or such without checking the computer out. So you would need to install some good antivirus, malware and spyware checking programs and see if the find anything.
You can also try starting up the computer in "Safe Mode" and see if you get the turning off and on problem in there. Granted, from "Safe Mode" you can't access a lot of things (it restricts access) however if it stops turning off and on in there, then you know there is something fishy on the device.
How to enter "Safe Mode" when booting the computer.
In Windows 8 and 10...
As your computer restarts, press F8 (possibly a few times) to enter "Safe Mode"
a. Press the "F4" key to Enable "Safe Mode".
(The computer will...