See some articles .
https://support.apple.com/en-in/HT204247
https://support.apple.com/en-in/guide/macbook-air/apdb468896e0/2019/mac/10.14.5
https://support.apple.com/en-in/HT206996
https://support.apple.com/en-in/guide/system-information/syspf5a64aa6/mac
As per the article https://support.apple.com/en-au/HT208532
Here’s how it works
Messages in iCloud are updated automatically, so you always have the same view everywhere that you use iMessage. If you have deleted a message, photo or conversation on one device, it will be removed from all of your devices. And since all of your attachments are stored in iCloud, you can save space on your device.
You can use Messages in iCloud on your iPhone, iPad and Mac.
Regarding the messages preferences when opened see the article https://support.apple.com/et-ee/guide/messages/icht20001/mac
https://support.apple.com/et-ee/guide/messages/icht1035/13.0/mac/10.15
- Set how long to keep messages: Choose Messages > Preferences, click General, then click the “Keep messages” pop-up menu and choose an option.
- Important: If you choose an option other than Forever, your conversations (including all attachments) are automatically removed after the specified time period is over.