When you say 'The gods', which gods are you referring to and how many of them?
Cavemen only knew about 25 of them but by the time of the great pyramids ancient science had found hundreds. These are each an anthropomorphization of physical principles. For instance, what we know as momentum or "upward" was named "shu" and was the very first god I solved. Words were representations and had no definition. They acquired their meaning from proper usage in a sentence and from their many names. One of shu's names was "he who embraces all thing". You couldn't think of shu without thinking of al his names you knew. If you used improper phraseology everyone would spot it and if it were simply wrong your utterance would have no meaning at all.
Not only shu built pyramids by taking stones up the sides but he needed "tefnut" (downward) to operate the henu boat filled with water and overseen by isis the goddess of the counterweight. It was tefnut who made the earth high under the sky by means of her arms; her arms being the cables strung across the pyramid top.
They didn't think like we do. "Gods" to them weren't imaginary consciousnesses that determined man's fate but rather they were the parts of their model of reality which was mirrored in their brains and speech. They were the parts of the model that caused reality to unfold as it does. Their simple science saw these only in human terms so shu and tefnut were siblings. What goes shu must come tefnut.
There is no magic of the sort imagined by Egyptology and the builders believed in no magic and no religion. These are merely confusions caused by our language, assumptions, and thinking.