Perform a clean install of macOS by erasing the whole physical SSD before reinstalling macOS. Who knows what condition macOS is in or what third party apps may be at play here or any system settings or modifications the previous owner may have configured.
The battery is unlikely to cause heating problems....if anything when there are power issues many times the CPU will be only running at idle speeds producing little to no heat.
Try running the Apple Diagnostics to see if any hardware issues are detected. If a third party battery is installed, then any battery errors reported by the diagnostics are meaningless unless you know for certain they diagnostics passed when the third party battery was first installed.
You can also try an SMC Reset.
FYI, here is what the previous owner should have done before selling the laptop:
What to do before you sell, give away, trade in, or recycle your Mac - Apple Support
Also, third party software such as anti-virus apps, cleaning/optimizer apps, and third party security software are the usual culprits for a computer running hot because they make the computer work harder even when the computer appears to be sitting there idle. Other third party apps such as file sharing & bittorrent apps will also cause a computer to work hard & heat up. Of course other apps & configurations could cause similar problems.
If the fans are running at high speed, it does not necessarily mean the laptop is running hot since the fans can run at high speed if any of the temperature sensors is not communicating properly.