If you didn't, then someone that has access to your account did. If you have another Trusted Device that is logged into your account, you can get the Recovery Key from that device.. If you set up Advanced Data Protection for iCloud, then it requires you to set up a Recovery Key or Recovery Contact, so if you turned that on, then you would have needed to set up one of those. When you are given the 28 character key, only you would have that information. Apple cannot recover that code for you because they don't have it.
This gives you more control of your account recovery methods and can help prevent an attacker from gaining access to and taking control of your account. However, if you lose your recovery key and can’t access one of your trusted devices, you’ll be locked out of your account permanently.
Set up a recovery key for your Apple Account - Apple Support