In light of this last post, I'd agree a reinstall would be for naught (and that's the worst kind of reinstall, isn't it?)
IF it does it in Safe Mode, I'd lean towards hardware being at fault.
How's about downloading one of the free memory testers from here:
Then, I'd go to the hd mfr.s site and download their diagnostics and run it...that could be an issue.
Rebooting while opening an app and while running defrag isn't really random...those are hardware-specific actions.
You do need to do a surface scan/scandisk...and it will mark and avoid bad sectors.
The command is
scandisk(space)/surface
I'm leaning towards this being the problem. Defrag will fail when bad sectors are being encountered (albeit usually with an error message) and the scandisk routine may mark them and avoid writing to them. It usually means the drive is headed south, tho, and the mfr. diagnostics will decide that.
You might locate and examine the scandisk.log (it will open with Notepad)
The not getting into the BIOS screens is maybe because of Compaq's splash screen getting in the way (hit the Tab key to see beyond it...F10 is usually the entry password.
This will give you some things to try.