Amazon, Google, FB etc have access to your photos if you share and/or store them there. As part of the terms of service, you give them blanket permission to scan those photos for facial recognition, sell them to ”partners,” give them to the authorities, use them in ads, or for any other purpose in perpetuity (so even if you delete them and close the account.
Apple does not. Microsoft doesn’t either, as far as I know.
All these companies, Apple and MS included, will hash (not “scan”) uploaded photos and compare the hash against a database of known Child Sexual Abuse Images (CSAM). Microsoft actually invented this technology.