Tarik Sektioui and Moncef Zerka were also on target for Atlas Lions to give them a huge victory over the Poor Namibia, whose only goal came through Brian Brendell.
Morocco bagged their first three points to be level with hosts Ghana, who claimed a 2-1 victory over Guinea in the competition's opener on Sunday.
Morocco needed just 60 seconds to open the scoring through Alloudi after some catastrophic defending from the Namibians.
Maroune Chamakh latched on to a long ball and raced through Namibia's area without opposition.His initial close-range effort went through the keeper's leg and struck the post. Chamakh gathered the ball again and fed Alloudi for an easy tap-in into an empty net.
The 24-year-old doubled the lead four minutes later when he caught Namibia defenders napping to receive Youssef Hadji's deft pass and slot home past the keeper.
Namibia grabbed a lifeline in the 24th minute, thanks to a controversial strike from Brendell.
Brendell collected a pass inside the area and poked into the bottom corner, but Television replays suggested the Namibian provider was offside in the build-up to the goal.
However, Namibia's goal counted for nothing as Morocco opened the floodgates afterwards.
Alloudi completed his hat-trick in the 28th minute when he connected with Sektioui's pinpoint cross at the far post to head home.
Porto midfielder Sektioui added the fourth five minutes before the break after converting a deserved penalty.
Zerka completed the rout in the 74th minute after towering to plant a header past the keeper after receiving a corner from the right.