The previous post is kind of a fun read and with good suggestions except #4. I would not unleash an antivirus program on your Apple device. I think you would have to try very hard to get any of that genre of nasty onto an Apple device, they have the system locked down so hard.
For a more staid and formal set of recommendations:
Read this document if you think your Apple ID has been compromised. --> If you think your Apple ID has been compromised - Apple Support
For iOS 15 or earlier, if you want to see if anyone else has access to your device or accounts, click here --> See who has access to your iPhone or iPad - Apple Support
For iOS 16 or later see how Safety Check on iPhone works to keep you safe. How Safety Check on iPhone works to keep you safe - Apple Support
Use the information in this document to check your Apple ID device list to find where you're signed in --> Check your Apple ID device list to find where you're signed in - Apple Support
Related materials:
Personal Safety User Guide
Personal Safety User Guide - Apple Support
> open the Table of Contents and review the articles
A document with general information about security and your Apple ID --> Security and your Apple ID - Apple Support
Contact Apple for help with Apple ID account security by clicking on this link --> Contact Apple for help with Apple ID account security - Apple Support "This article provides country-specific Apple Support contact information for customers seeking help with their Apple ID password or other security-related issues."
Also consider that all these messages may be pure phishing. They may not even really be from Apple or have any kind association with an attempt to log into your account. Scams (e-mail, text messages, and phone calls) are getting very good at closely imitating true Apple communications. Always be cautious. These support articles have some guidelines:
About identifying legitimate emails from the App Store and iTunes Store --> Identify legitimate emails from the App Store or iTunes Store - Apple Support
Recognize and avoid phishing messages, phony support calls, and other scams - Recognize and avoid phishing messages, phony support calls, and other scams - Apple Support
Avoid scams when you use Apple Cash --> Avoid Apple Cash scams - Apple Support
Apple 'How to identify, avoid, and report phishing' video--> https://youtu.be/SR3Z3fXXjfw
About Gift Card Scams --> About Gift Card Scams - Official Apple Support
If you are uncertain about a message and a resource provided in that message, do not click on any links in the message. Try to independently verify the resource by going to a support article page on apple.com and use the instructions in the article to verify though Apple itself, or your Apple device features such as Settings or an Apple app, what the message is claiming. To ask Apple start at this web page: Official Apple Support