Azzedine Ounahi scored two of three second-half goals as Morocco ended cohosts run to reach last eight.