What is your origin airport? What are your travel dates? Is this a round-trip to Morocco, or are you going on from Morocco to other countries?
You can certainly purchase separate tickets to Morocco from Spain, and quite likely from other European countries, but of course through-tickets are far better, since you don't have to worry about losing the second ticket if the first flight is late, and your luggage will be checked through.
I suspect you may be running into airline-partnership issues. Perhaps the carrier(s) serving your home airport do not have interline agreements with airlines flying to Morocco. But without knowing your home airport, I'm just speculating.
One other thought: Are you trying to fly into a city other than Casablanca? For a transatlantic connection, you may need to use Casablanca as your gateway. Incidentally, I see that AirMaroc has a nonstop from Washington-Dulles to Casablanca. I am guessing it's not a daily flight, but I have not checked.