you could boot into Safe mode and if computer does not restart, lean to software. if it does, lean to hardware as the cause.
start by making sure you are flashed to latest bios version and have latest motherboard drivers installed.
then, it could be either and how to narrow it down? xp comes configured out of the box to reboot on some system errors. check it out System properties/Advanced tab/Startup and Recovery.
you are seeing bad system error which is rebooting system upon shutdown. change the setting and you instead will get a blue screen error shutdown. post entire thing or look it up yourself at support.microsoft.com knowledgebase.
you might also have already gotten a virus. turn on the xp firewall (it comes turned on out of the box) and get all the xp critical updates and service packs applied.
it you have cd burning software, check out if you need upgrade for xp. ditto for all your applications