No, messages will not be on the laptop if you erased it unless you log back into your AppleID again.
You definitely need to remove your AppleID from managing this device. At the very least you need to remove this old laptop from FindMy. This is most easily done before erasing the computer, but you can still try to remove it from iCloud by using the instructions in these Apple articles:
Turn off Find My on your devices and items - Apple Support
Remove a device from Find My on Mac - Apple Support
Here is an Apple article with all the steps you should perform when preparing to sell a Mac (most of them need to be performed before erasing it):
What to do before you sell, give away, trade in, or recycle your Mac - Apple Support