When you get the email, check your device list to see if there is a device signed in that you don't recognize. You can remove the device using the steps in the article below. As a precaution, change your password.
Apple ID device list -Check to see where you‘re signed in.
Apple ID Password Change.
What to do after you change your Apple ID or password - Apple Support I suggest doing this before you change your Apple ID or password.
You can also add 2 Factor Authentication to your account for more security. If the attempts continue, you might want to consider a name change.
Link to contact Apple Support in the article.
Apple ID has been compromised.
Security and your Apple ID.
Apple ID Password Change.
Note the restrictions in the article.
Apple ID Name Change.
What to do after you change your Apple ID or password - Apple Support I suggest doing this before you change your Apple ID or password.
Apple ID -Two-factor authentication
Two Factor Authentification availability.
2 Factor Authentication - How to generate a recovery key
Apple ID - Using app-specific passwords.
Apple ID - Two Step Verifications FAQ