If it shows charging with nothing plugged in, I'd suspect dirt in the charging port.
Shutting itself off, and then ... If turning it back on shows that the battery is still charged up to 40% or more (you should never discharge a lithium battery lower than 40%), you could have a battery growing a dendrite. That would mean a battery replacement. (There's nothing the manufacturer can do to prevent that - the lithium battery industry is still trying to figure out how to prevent dendrites - after quite a few years.)