They are both correct. The words 'American' and 'Moroccan' can be be both adjectives (as in 'He is Moroccan') or nouns (as in 'He is a Moroccan').
This works for all nationalities which end in the letter 'n' - Algerian, Canadian, Brazilian and so on. 'He's Brazilian' (adjective) or 'He's a Brazilian' (noun) It also works for nationalities ending in 'i' : Kuwaiti, Saudi, Pakistani and so on can be either nouns or adjectives. A few nationalities ending in a 'k' sound, such as Greek and Czech, can also be nouns.
That is the easy part.
Unfortunately, this doesn't work with most other nationalities. You can't say 'He is a French' or 'He is a British' or 'He is a Spanish'.
A few nationalities have a specific nouns to refer to the people : Spaniard, Turk, Dane, Swede, Finn and Scot are examples of these.
So what about all the other nationalities? In a few cases, we can add 'man' (pronounced /mən/ ) to the nationality, as in Englishman, Irishman, Dutchman and Frenchman. This is a little old-fashioned, and doesn't work so well for women and children, so it's less useful, and only applies to a handful of countries.
So, in many cases, there is no noun to refer to a person in terms of their nationality. We can't say 'Lee is a Chinese' for example, so we have to say 'Lee is a Chinese woman' or for example, or 'Lee is a Chinese student'. There simply is no noun we can use here.
So, it's not surprising that you are confused. It is a very confusing and in many ways unsatisfactory part of the English language. I wish it were simpler.