Yes you are right luck is also important for win in some matches and definitely Morocco was lucky enough to score all 3 penalties, but we can never deny their presence of mind while scoring penalty they were confident and full of energy. Spain on other hand were very nervous and confused during penalty shootout and as a result they couldn't make it.
So lesson is while you are in game don't be nervous and tense give your best.
Spain look like under mental pressure as they failed to score repeatedly. There were many chances that should have been goals, but Morocco had a second goalkeeper on the pitch, the goalposts. During a normal time, Spain almost managed to score a goal, unfortunately the goalposts made the opportunity disappear. Even in the penalty shootout, Spain experienced the same thing. Because they are have a lot of star players and become favorite team, failure to score in 90 minutes against a team that should have been able to beat ended in a penalty shootout making them more struggle. But, i think this results is not because a luck, since world cup 2018, Spain also getting struggle face Morocco, and the match ended with draw result.
L Enrique should have done better with his tactics, change some players and change of formation he should have gone pass this level but all the faluire should be on his head.
Though, Morroco sat back for Spanish side's to attack them and hit them with counter attack's. Special kudos to Amrabat of Morocco he had an individual performance I can never forget, I will forever have it up in my head.
Also during the penalty shoot out, they should have used another set of players at least for the penalty shoot out.
It's a big congratulations to Morocco because a win to them and from them is a win for all African sides. Team Portugal ahead, Morroco honestly will be knocked out by Portugal.