Thank you for the additional information, @amir0985!
This is one of those problems that is very difficult to diagnose. It could be a number of things causing it to happen. However, I still believe that it could be the power adapter. I suggest that you have it tested. Since it doesn't matter if it is plugged in or not and the battery is healthy, and it mainly happens when you first turn on the laptop, it sounds like there is a short in the adapter. After it runs for a bit the heat causes the wires to expand and no short.
I had a similar problem with a desktop years ago. The power supply unit (PSU) had failed.
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".