tl;dr – The two airlines are both members of the oneworld alliance.
Fellow oneworld alliance airlines and flag carriers, Malaysia Airlines and Royal Air Maroc, recently entered into a codeshare agreement with the ultimate goal of “enhancing connectivity across Africa, Europe and Asia.”

“As part of this agreement, Malaysia Airlines will add its ‘MH’ code on flights operated by Royal Air Maroc between Casablanca (CMN) and Doha (DOH), London (LHR), and Paris (CDG). Meanwhile, Royal Air Maroc will add its ‘AT’ code on flights operated by Malaysia Airlines between Kuala Lumpur (KUL) and Doha (DOH), London (LHR), and Paris (CDG).”

Both airlines are seeking to increase their global presence and build up traffic through their hub cities of Casablanca and Kuala Lumpur.