Christianity in Morocco dates back to Antiquity, it was widely propagated during the roman era. After the collapse of the Western Roman empire, Christianity still existed even in remote places, like the city of Aghmat which was a Christian city by the time of Islamic conquests.  Unfortunately, there is no more christian building still standing from that period or from the medieval age.
During the beginning of the XVIth century, Portugal conquered parts of the atlantic coasts of Morocco, therefore, they built some religious buildings, some of them are still standing, but some others are deteriorating like the cathedral of Safi.
After being chased by Morocco, Portugueses came back to Morocco along with other Europeans, not as conquerors, but as merchants and ambassadors. It was during the XVIIIth century, in the city of Essaouira, that they've built a small church, which is still standing but in a very bad shape. 
In the XIXth century, two churches were built in Tangier, one by a Spanish governor  and the other by the British community living there. 
Another one was built inside the Medina of Casablanca, after the Sultan gave a piece of land to the Spanish kingdom, to built a church for the Spanish community living there. 
The XXth century was marked by the French and Spanish "protectorate", it was during that time where the majority of churches in Morocco were built.
NB: I may have forgotten some churches.