The Moroccan conquest of Songhai didn't fail because of mismanagement. It failed because Morocco couldn't rule such a far away place separated by the Sahara Desert for any amount of time. After the initial pillaging of gold, there was no benefit at all which is why the garrisons were abandoned and Morocco never came back. It's the type of dramatic lunge that can be attempted by many countries, but exerting real control as opposed to smashing an enemy force requires a lot more power, wealth, institutions, and technology.
If you strategy is to have "more brilliant leaders" then you are in trouble as there is no way to guarantee that from happening. Its institutions that matter in the long run. If you are dependent on indivduals, any country can get lucky with 3-4 great leaders in a row. Usually they are very sporadic and separated by mediocrities or utter incompetents.
Morocco certainly could expand into Algeria and Tunisia as there had been many North African powers that did. That would make it a strong regional power, but not a great power unless it happened very early. But then you are not talking about Morocco at all, but some new pan-Berber North African state. If that happens too late, then the Europeans and Ottomans are already ahead. Without the Ottomans threatening the western Mediterranean, Spain would likely control much of the Barbary Coast.
North Africa never really recovered from the invasion of the Beni Hilal who ravaged the old agricultural base that went back to Roman times. It had the Saharan gold trade, but that declined just as Europe began expanding overseas. It is hemmed in by the Sahara, limiting expansion. These are major disadvantages.
Certainly there is more opportunity the further back you go. But hearing the terms "Meiji" and "modernization" makes me think the original poster is thinking more about a mid to late 1800s POD.
Umm Just to clarify i meant that by mismanagement the morrocans fell prey to France which conquered them. I just said Songhai was conquered by Morroco
I think best POD is in the 1500s. For some reason or the other the Ottomans havent defeated the mamelukes of Egypt. Maybe a greatly weakeaned Ottoman empire.
Morroco after conquering Songhai decides to "Unite" the Berber people under Morroco. So Morroco invades Algeria and Tunisia conquering both areas.
From their it takes advantage of the mamelukes internal discord and invades the libyan territories siezing them and bringing them under Morrocos control.
Next have the Morrocons ally with Britain against Philip von Habsburg.
Spanish armada gets destroyed like otl and the Spanish navy is decimated.
Then Morroco allies with France and convinces the French king to declare war on Spain and go for round 2 against Spain.
With the british blockade and French invasion the Spanish army lies in ruins.
Have the morrocons in this period bribe spanish officers and soon the morrocon military trains in the Tercio formation.
Then with no Spanish navy Morroco invades Granada and such areas. Then have the morrocons convince the Portuguese to sieze land from the habsburgs.By 1600s the southern Spanish coast lies in Morrocon hands and Spain is broken as a power with its navy destroyed and facing a multi fronted war it crumbles.
Also the Ottomans cause their own havoc by invading Hungary, Austria, etc not to mention the protestant and Dutch independence wars fought by Spain.
Thus the Morrocon empire now controls the southern Spanish coast, algiers, tunisia, libya, and Songhai. I'm sure that this Morrocon empire has a chance to develop into a major power Maybe not a great power but a very strong regional power that is able to resist european advances.
BTW if he is looking for one in the 1800s.. That is ASB it is impossible for Morroco to do anything by that point. france will take it sooner or later.