Upvote:5
The Spanish were able to resupply Ceuta by sea. Moroccans were not capable of preventing that. At that time the Spanish navy was no longer the world's dominant sea power, but more than powerful enough to protect resupply runs.
When you read about extremely long sieges, lasting many years or even decades, it's always a resupply issue. As long as the besieged can get resupplied, there is no reason for them to surrender.
As to your other question, that was a matter of prestige, for both parties. The Spanish didn't want to loose their holdings in Africa. They certainly did not want to loose them to 'barbarians'. Don't forget that the entire north African coast was named Barbary Coast in that period.
For the other party it also was a matter of prestige. They wanted to kick the infidel invaders out. Just as Gibraltar today is a hot issue for Spain - which incidentally was captured in 1704, and greatly hindered resupply - Ceuta was and still is a hot issue for Morocco.