In order to understand the issue between Morocco against Algeria and Spain, you should turn back to the history, which I'm going to explain to you by myself and if you want to make more researched you'll do right..I don't understand this continuous reference to Spain,Morocco won't ever go to war with them unless it has a suicide wish.
Spain, was occupied by Morocco for over 800 years, Andalusia was belonging to Morocco at some point, because the Andalusi Princes couldn't support the Christians attacks, that the whole Churches of Europe was supporting by solider and weapon, in order to free Andalusia from the Muslims, so the Moroccan Empire back then, was supporting the Andalusi Princes in their wars, and they always were defeating the Christians over there, one of the Moroccan Kings who supported Andalusia is Yusuf ibn Tashfin, you can look for him in Wikipedia, so he lead the Moroccan Army back then going to Spain, and defeated the Spanish and European Army in a war called Zallaqa, you could look for it "Battle of Zallaqa", so this war will give you an idea about the Moroccan Spanish conflict, the Andalus was defeated at the end, and the reason was because of the Andalusi Princes, because of family problems, one of them was mad and he helped the Christians against his brothers, so they were freeing Andalusia state by state to the Christians, the time that Moroccan Empire wanted to help it was too late, because the inside problem wasn't expected..
Above all of it, Spain wanted to occupy Morocco, and they got an incredible resistance by the Moroccan Citizens, because the time Spain attacked, Morocco was going in a War against France in the south, so the Moroccans Citizens defended themselves, and that was the time when Spain had the biggest defeat in their Early History, 3,000 solider from the Moroccan side, and 27,500 solider from the Spanish side, 1,000 died from the Moroccan side, and 13,300 from the Spanish side, so they withdraw their Army because if they would continue, no solider would go back alive to Spain, and another war as well, Morocco and Ottoman support, against Spanish and Portugal Empire, 60,000 from our side, and 300,000 from Spain and Portugal, no one died from the Moroccan side except the Moroccan king, because he was who leads the Army, and from their side, the whole Portugal royal family was killed, and a Spanish king, 8,000 died and 15,000 captured and the rest ran back to Spain..
The Moroccan Spanish conflict is so old, we always had the victory, with basic weapon, and man who loves death more than life..
The Moroccan Spanish conflict will never end, only if they kill us all, or we kill them all, a war will come, it's a matter of time..
When comes to what's before the war, its always possible to take Ceuta and Mellilia back without any war, and that's what the King is looking for, he built the largest Port next to Ceuta, who's classified as the largest in Africa, who beats the Moroccan occupied port in Ceuta, even the Moroccans who comes from Europe, they prefer entering Morocco by the Moroccan Port than the Spanish, so that kills the Spanish economy from a side, and secondly, a city, whole city is created next to Ceuta, will be based on the goods that comes from Europe and the whole world, because there's too many Moroccans who live on buying goods from Ceuta, and selling it in Morocco, the time they stop them, these families will have nothing to eat, so they're building a Moroccan project in Parallel, to kill the economy of Ceuta..
Just an additional information, Ceuta gets water, electricity, internet, food and all the basics from Morocco, and another thing, my city is the closest to Ceuta, called Tétouan, we go to Ceuta without a Visa, we're allowed, and the rest of Morocco isn't allowed, if Morocco applies the Visa to us the Tétouani, we no longer can enter Ceuta, and the Spanish economy will absolutely die, that why Spain lately is running in order to please the Moroccan side, the Spanish King was lately in Morocco, in order to study the future mutual projects, so I'm telling you, it's a matter of time and we open them the hell doors
This is a picture of the Moroccan Empire, and as you can see, Andalusia was a part of the Moroccan Empire, Algeria as well, and several countries of Africa