I asked my teacher this and she looked at me like I was crazy. I started to search it up but nothing interesting showed. Could you please explain as I am very curious.
The confusion here is that what is popularly conceived of as the "collapse of the Roman Empire", is really only the collapse of the Western Roman Empire. The Roman Empire persisted in the East for roughly another 1,000 years. Egypt was in the Eastern Roman Empire.
Since the conquests of Alexander the Great, Egypt had been ruled by a Greek speaking Greco-Macedonian elite. When the Romans conquered the Eastern Mediterranean the local Greek speaking elite essentially Romanized and became the local Roman ruling class. The local Greco-Roman elite did not really integrate with the native population, and when Egypt converted to Christianity in the 3rd and 4th centuries, the local population converted to a different form of Christianity (Coptic) than the Greco-Roman population, solidifying the distinction.
The collapse of the Western Roman Empire had a relatively limited impact on Egypt.
Egypt continued to be ruled by the Eastern Roman Empire, it was then conquered by the Persians briefly in the final war between the Romans and the Persians, then it was reconquered by the Romans.
Finally Egypt was conquered by the Arab Muslims, and gradually an Arab Muslim elite replaced the pre-existing Greco-Roman Christian elite. The local populace started to convert to Islam, which accelerated in the 9th century, but a significant Coptic minority still remains.
It's arguable when Egypt actually regained its freedom, the Fatimid Dynasty was based in Cairo starting in 973 AD, but they practiced Shia Islam, and the vast majority of Egyptians were either Sunni Muslims or Coptic Christians. You could make an argument that Egypt never really regained its freedom until the 20th century because all of the rulers of Egypt up until then were either foreign, from a foreign ethnic or religious group, or subordinate to a larger empire. That takes the story a bit too far afield for me, but it's safe to say that Egyptian Freedom was not a consequence of the collapse of the Roman Empire.