If, like a lot -if not most - of people you enabled iCloud , the messages wouldn’t be encrypted up till very recently (two months ago)Not sure what you're talking about... iMessages has always had end to end encryption.
Yes, if you had "iCloud Backup" turned on and had "Messages in iCloud" turned on, then a copy of your "Message in iCloud" key was backed up along with your messages - which was absolutely necessary in order to decrypt those messages to restore them back onto your devices.
However, with Advanced Data Protection turned on, your entire iCloud backup is now encrypted with a key that stays on device.