The feature you are asking about is called Cleanup. To get Cleanup, you have to enable Apple Intelligence on your iPhone, and once enabled, you then open a photo, tap the icon next to the trash can with three sliders in it, which is the edit function. Once you're in edit mode, you'll see Cleanup, which the first time you ever tap it, it downloads, then you can use the Cleanup feature.
Have you enabled Apple Intelligence on your iPhone? To get Apple Intelligence, make you meet every qualification as detailed in this link --> How to get Apple Intelligence - Apple Support (CA)