I am providing you solutions which will help you in preventing installation of any app which you do not want to install automatically or from outside of the Windows Store.
Prevent Programs From Installing Through Windows Settings
You can easily disable the feature that will prevent you from installing the third-party app even if it is a desktop app. You can only install the Store apps by applying below steps. And if you try to install any app from outside the Store or desktop app, a pop-up message will appear which says that “you can only install apps from Windows Store”.
Block new installations through Registry Editor
Some users said that few apps from Store get automatically downloaded like Candy Crush or Candy Crush Saga, even if they do not need those apps. Here is an easy trick to stop installing any app from the Store to have maximum free disk space for other useful purposes. This should give you some protection against automatic software installation or even if you want to install software yourself but the software has not been verified from Microsoft, Windows 10 will not let you install it on your computer. This can be a great security measure on sensitive systems and a great saver from ransomware. Also see:
5 Ways to Enable/Disable Automatic Updates for Microsoft Store Apps in Windows3 Ways To Remove/Disable Microsoft Account In Windows 11/103 Ways to Bypass Upgrade Blocks (Safeguard Holds) in Windows 102 Ways to Disable All the Settings of Windows 10 Taskbar4 Ways To Block Windows 10 May 2021 Update (v21H1) from Installing