If you use Remote Desktop Services (RDS) to provide shared computers to users in your organization, you can install Microsoft 365 Apps on those computers. But, you have to use the Office Deployment Tool and enable shared computer activation to do the installation. This article will describe how you can do this.
A Microsoft 365 subscription that includes Microsoft 365 apps for business or enterprise;
Office deployment tool.
Microsoft has their own article for this. Therefore we recommend to follow their guide. You can find the article: https://learn.microsoft.com/en-us/deployoffice/deploy-microsoft-365-apps-remote-desktop-services#install-microsoft-365-apps-on-an-rds-server.