Hey there, sorry to hear.
1. If you're saying that sometimes the PC will stay on but fail to POST, (or show your motherboard logo) be certain it's not something as simple as the display. Try different cables and use another PC/Laptop or even a television to test.
2. If that fails, make sure that all PSU cables to your motherboard are plugged in fully and correctly. The 4-pin connector, usually located in the top-left of the motherboard, can cause the issue you're describing.
3. In my experience if you turn the PC on and it turns off almost immediately it generally points to a motherboard issue. It's especially common after a power surge or something of the like.
In this case you may need to have it looked at by a PC repair shop.
If...