You most likely have a virus. Have you been looking at super sexy, hot, gay, mario porn and milkin yer rod? That could be the problem.
If I plug in PSU cable into the wallsocket, turn on the PSU switch and press power PC starts but turns itself off a few seconds later, only to turn itself on few seconds later.Not happen if I shut down after boot&turn it on. What could problem be?
Cold Start/Startup - a start of the device from an electrically powered down state. By that I mean unplugged from the wall, unplugged from your UPS, or the power switch on the power supply turned off.
Warm Start/Startup - a start from a powered down status as when you do a system shutdown. A warm boot leaves power to the system motherboard, power supply, and CPU. This is sort of like when you turn off a modern television, there is always still a very small charge on vital components maintaining the system in a state for ready for reactivation to full operational status.
1. At what point is the PC restarting automatically? Is it prior to loading your operating system?
2. Does it happen when you try entering BIOS setup?
3. Does it only happen when you do a cold start?
4. If you answered yes to any of those three questions, you may have a hardware problem starting. Among the candidates are:
a). The battery backup for your motherboard BIOS. That is a very cheap fix as a replacement battery will cost you less than 10 dollars.
b). The main power supply (less likely). This is more expensive but still reasonable depending on what hardware is on your system that it has to power and if you can do the replacement yourself or have to use someone else like the Geek Squad (last I heard they charge like $100/hour).
c). Your motherboard is failing, most likely a capacitor. You should consider a new motherboard or computer. IF it is the motherboard, if you cannot do the work yourself or someone that is a friend that will do the work for free, a new computer might be cheaper.
Regardless if one of the three is the situation and the problem only occurs prior to the loading of the BIOS, you are unlikely to lose any data from continuing to use the system for a bit. You should have it checked out by a knowledgeable person though.
While in system startup, you are only reading data so no chance of data corruption on your media, there is a very small chance if you are using rotational data storage (old fashioned hard disk) for your boot device that a corrupted instruction could be sent to the boot device resulting in a head crash. If you boot device is a USB drive, CD/DVD, SSD drive, SSD drive that plugs into a PCI-E slot or a SSD that plugs into an NVME M.2 slot, this SHOULD not be a problem (still no guarantees).
5. If it occurs during system startup (loading of the operating system), I would suggest: Get a copy of the latest UBUNTU Linux distribution and make a boot disk. Try booting and running from the boot disk. If no problems occur, your main OS has either a virus, a bad operating system patch, an operating system patch that conflicts with one of your device's firmware, a bad firmware, or you are executing a job that required a system boot to continue executing. The last of these is least likely as it should be able to continue after any successful boot but there is the very rare exception that requires a cold start.
If you have a Windows computer, you may boot the system in safe mode. This will prevent the installation of drivers not supplied by Microsoft. If there are no problems, a system restore from prior to the start of the problem may fix the problem. Other places to check are the startup folder and MSConfig but I would really expect them to always generate the problem not occasionally or only with a cold start.
6. I can really not think of a lot of reasons for this to happen after system startup (operating system fully loaded). The likelihood of anything other than a virus as it occurs within seconds of completion of system startup is very low. I would suggest reloading your operating system from a know good system image or your original operating system media. Perhaps a very knowledgeable friend can help or the Geek Squad, they will check for and clear viruses for less than $150.
7. Have you added any new devices to your system recently? This could be the source of the problem as the driver software may have conflicts with the operating system. Get the most recent drivers for you specific operating system and install those drivers.
Without seeing the situation as it occurs, this is the best information I can provide. Might I suggest that you record a video of both when the situation occurs and when it does not and then post the video on youtube with a link in the question to the video. It would help greatly.