Before install check to see if an application is installed before proceeding

Depending on what software deployment platform you are using - you could configure a dependancy, to do just this so you don’t have to do it in a script (It’s sometimes better to have all the apps separate and maintained by the deployment platform)
In Intune I have quite a few apps configured with dependencies, So here is an example:
For Adobe Photoshop 2024 (v25.2) I have configured a dependency defined that requires Adobe Bridge 2024 (v14.0.1) to be installed:

For users devices that are instructed by Intune to install a particular app if the dependent app (Adobe Bridge in the above example) is already installed, it will proceed with the install of the App containing the dependency (Adobe PhotoShop in the above example).
If however, the dependent app is not already installed, it will automatically install this first (Bridge) before installing the App containing the dependency (Photoshop).

I hope that makes sense?