Initially, the ancient inhabitants of Egypt believed that spirits protected plants, animals or things. For this reason, in order to protect themselves from the anger of these spirits, they began to offer them sacrifices.
Over time some of these spirits were left in this condition and others were elevated to the category of gods.
Egypt occupied a very large territory and was divided into 42 provinces, and in the capital city of each of them one of the great gods was worshiped. They built him temples cared for by priests who guarded their god. Each of those provinces thought their god was the only almighty.
When one community was absorbed by another, the most important community made its god predominate over the other. Thus, when the city of Thebes became the Capital of all Egypt, its god Amon gained the most important place, replacing the local gods of the other cities.
Many times, priests grouped several gods in one temple as if they were a family of father, mother, son or daughter.