This depends on the app. If it is a free app, make sure to install it from App Store as the files are scanned and verified by Apple. However, if it is premium apps like Microsoft 365 then you should purchase a subscription from Microsoft. After that you can install the app either from your Microsoft account or from App Store and link the subscription. Otherwise, you will have to wait for the expiry of App Store subscription to change the subscription from Apple to Microsoft when renewing.