With the release of the 2107 version of SCCM, you can now automatically uninstall application when the device is no longer part of the collection the application has been deployed to.
To be able to enable the ‘Uninstall application if the targeted object is no fails out of collection”, you need to deploy the application as required.
This option is only available for deployment targeting devices collection.