Where there are no trains, busses take over the transportation. There are two mayor bus companies operating in Morocco: Supratours and CTM. Supratours is often located near the train station as it is part of ONCF. Both companies have comfortable busses and also offer Comfort plus options on some popular routes like Marrakech – Agadir. There is no need to buy the tickets for busses and trains in advance, I always make sure to arrive half an hour in advance to buy the ticket at the station. However, on the popular route from Fes to Chefchaouen, tickets might get sold out so here I would advise to buy your ticket at least a day in advance.
Of course, the public transport does not reach every corner of the country, so if you are planning on visiting the real remote places of Morocco, you either have to take a shared taxi or drive yourself. Often there are possibilities to take a bus and then a grand shared taxi. These taxis wait until they are full, which means you sometimes have to wait before you can leave.