It does not make a lot of sense, but it was sort of established earlier in that particular universe (the “phenomenal cosmic powers, itty bitty living space” thing).
My main problem with this always was Aladdin suggesting to Jafar “Hey, you know, the genie’s still more powerful”, and Jafar reacts exactly how Aladdin had planned, by wishing specifically to be the most powerful genie.
Why was that the only option he could think of? Where was it written that a sorcerer could not be more powerful than a genie?
Aladdin tricks him by saying if a genie gave him his power, the genie could take them back too… But in the end it’s still the genie who makes him a genie too, so why would that be any different?