Why do you think Alexander continued to Egypt after "liberating" the Levant/Phoenicia? Wouldn't it had made more sense to pursue Darius instead of giving him time to summon his full forces for the next battle?
There are two reasons for ATG to go to Egypt, one political/military, the other personal/religious.
First, seizing Egypt allowed him to "sew up" the Med coast, sealing it against the Persian fleet. This was why he went down to Phoenicia in the first place. Once he had Gaza, he was probably good, but Egypt was an easy win. They routinely rebelled against Persia and were willing to make a deal with the devil, so to speak.
Egypt was ancient, and proud. They’d hated overlords since Assyria. So why accept Alexander without resistance? He had NO intention of staying there and would likely (re-)appoint a lot of known quantities. The Egyptians were no dummies; they'd taken his measure. Flatter him, submit willingly, make him pharaoh, and he'll be in a good mood and be nice to them. He needed their affirmation. Egypt might no longer have a lot of political power, but (like Babylon) it had a lot of SYMBOLIC power. (And it was also wealthy in resources.)
So there was every reason in the world for ATG to take a detour to Egypt. It's not really a detour at all. It was a friendly place that would let him relax his men in preparation for the Big Battle to come, and seal his control of the Mediterranean Basin, plus get to add pharaoh to his titles.
Now, the personal/religious reason: his trip to Siwah. He may have been planning it for some time, events allowing. (Remember WE know how Issos fell out, and Tyre, etc., but HE didn’t in advance.) Yet there’s an intimation of divine recognition as early as going through Miletus and his visit to the Oracle at Didyma. Alexander was great at staging himself, extremely conscious of religious significance and his putative divine parentage. While I say he "staged" himself, that doesn't mean he didn't absolutely believe in his divine descent (from Zeus via Herakles, and Thetis via Achilles). He did.
But with his recent extraordinary successes, and patterns set by his father treading on the divine robe (note Philip making a 13th statue of himself to sit among the Twelve on the very day of his death), Alexander may have been reaching for more than distant divine descent. The awarding of heroic honors to the recent dead—and even to the living (Lysandros of Sparta)—had been growing in Greece throughout the 4th century. Alexander was just continuing a trend. I give less credit that some to supposed insinuations from his mother. I think that's post-Alexander anti-Olympias propaganda, or post-Alexander pro-divine-Alexander propaganda. I don’t think he needed his mother’s stories, even if those stories did predate his Asian Campaign—of which I’m not convinced. (In the novels, I DO play with that, but it’s fiction.)
Siwah was personal. Yes, he used it politically, but I believe it was a personal quest. It took time, and Alexander was known for not letting grass grow under his feet. He tended to win because he got there before people expected him to. Spending all that extra time in Egypt to visit Siwah—even if it rested his men—also gave Darius extra time to prepare for Alexander’s assault. It had to be very important to him, to “waste” that time.
So while going to Memphis in Egypt to be crowned pharaoh was not an unreasonable choice for him to make, the amount of time he spent in Egypt—and specifically his trip to Siwah—was a bit more notable.
But even World Conquerors have personal dreams.