I had this problem once with my HP AIO-PC 23-p110, which I think is the 2014 model. There were several posts online about soldering and some stuff about something getting worn or disconnected inside the machine, but my machine had barely been out of the box, so I didn't want to go that far.
The problem reminded me of a problem I had with my PlayStation 4 (PS4), which is somehow related to the power supply inside the machine (PSU). Without turning this into an answer to a question you didn't ask, what I ended up doing was pulling the plug from the back of the machine (not the wall), waiting a while (couple hours), and then plugging it back in. This got it to turn on. Once it was on, I did what I did on the PS4 and modified the power settings in the system. I extended the time it takes for the machine to go to sleep or turn off. This way the PSU is regularly getting power.
Both seem to be working fine now. I hope this helps.