It sounds like you may have discovered why the previous owner wanted to get rid of this laptop.
Sounds like a hardware issue of some sort. My first guess would be a possible damaged USB-C port (best case for you as it is inexpensive). Other possibilities are a bad USB-C charging cable or Power Adapter, or a bad Battery (never had one do this though), or a bad (more likely damaged) Logic Board. There is no way to know for sure without having a tech physically examine the laptop closely.
It is very easy for a tech to examine the USB-C ports once they have been removed from the laptop (no other way to be sure since some damage may not be easily visible otherwise). And a tech would want to closely examine the Logic Board for possible liquid damage or a loose connection with the Battery. There is also a very likely possibility a previous owner replaced the original Apple OEM battery themselves with a third party battery (most third party Lithium Batteries are of extremely poor quality....sometimes even when purchased from a well respected vendor).
You can try the troubleshooting steps in the following Apple article to see if any of it helps:
If your USB-C power adapter isn't charging your Mac laptop - Apple Support
My hunch is damaged USB-C ports at the very least followed by the Logic Board being damaged, but the power adapter & charging cable are both possibilities as well with the latter two being the only things you can control & test yourself.
You can try running the Apple Diagnostics, but they don't really do much these days and the results can be misleading.