See the following from Two-factor authentication for Apple ID https://support.apple.com/en-us/HT204915
When you sign in on a new device, you’ll get a notification on your other trusted devices that includes a map showing the approximate location of the new device. This is an approximate location based on the IP address the device is currently using, rather than the exact location of the device. The location shown might reflect the network you're connected to, and not your physical location.
If you know you’re the person trying to sign in but you don’t recognize the location shown, you can still tap Allow and continue signing in. However, if you ever see a notification that your Apple ID is being used to sign in on a new device and you're not the one signing in, tap Don’t Allow to block the sign in attempt.
Consistently you can Check your Apple ID device list (https://support.apple.com/en-us/HT205064) and remove any device that shouldn't be signed in using the steps in the link.
If there are none that shouldn’t be signed in, then you should not have a problem at this point. But, if an unauthorized device signed in, Change your Apple ID password https://support.apple.com/en-us/HT201355
Here is What to do after you change your Apple ID or password https://support.apple.com/en-us/HT204071
And see these security-related Apple Documents:
If you think your Apple ID has been compromised https://support.apple.com/en-us/HT201303
Security and your Apple ID https://support.apple.com/en-us/HT201303
iCloud security overview https://support.apple.com/en-us/HT202303
Ways to keep your information safe on Mac https://support.apple.com/en-gb/guide/mac-help/mh11402/mac
Using app-specific passwords https://support.apple.com/en-us/HT204397