Greetings,
Welcome to the forum.
I am not a HP employee.
This symptom could be caused by a faulty power switch.
It could also be caused by a failing external power supply or a motherboard problem.
It could be caused by a peripheral device connected to the PC.
It can also be caused by a component connected to the motherboard.
You have to check all of these items to find the problem. You can troubleshoot if you like doing this.
I recommend you have HP check the PC (Link) or have a local PC tech take a look.
Very hard to fix this type of problem in a forum.
Regards