Hi, I'm John! I will help you with this.
If you did not request the code, do not use it and do not click any links in the email.
Can you share the sender email address so we can check if it is really from Microsoft? Please hide part of the address for privacy.
Sometimes this can happen if someone accidentally entered your email while trying to sign in, Or someone knows your account credentials and is trying to access the account. Have you already changed the password for that account?
If you haven't already, I would recommend checking the recent activity page and changing the password if you have not done so already. Also make sure two-step verification is enabled.
You can check account activity here: https://account.live.com/Activity
"How to help keep your Microsoft account secure" https://support.microsoft.com/account-billing/how-to-help-keep-your-microsoft-account-secure-628538c2-7006-33bb-5ef4-c917657362b9
Click "Add comment" to let me know.