Foreign nationals can operate in Morocco either by creating a company under Moroccan law, by choosing the SARL (the equivalent of the LLC) or the SA (the equivalent of a Corporation). They can also establish a representative entity of a Foreign company, in this case, for tax purposes, these entities are qualified as permanent establishments (branch, liaison office, coordination office, a subsidiary, etc.).
More details on the legal entities, as well as their definitions, can be found in this link: https://arkadplus.com/business-entities/