@monsesilo -- that is only a few details. More details would be helpful to give a better response.
It could be a failed fan that is detected by the motherboard, and the motherboard is shutting-down the computer, to prevent damage caused by heat. It could be a failing power-supply. It could be a failing motherboard.
I recommend that you take the computer to a professional computer technician, for trouble-shooting.
Be alert for scammers posting fake support phone numbers and/or email addresses on the community. If you think you have received a fake HP Support message, please report it to us by clicking on "Flag Post".