Eastern prayer, perhaps specifically the anaphora of St John Chrysostom, made a connection between the Our Father and the doxology. When copies were made of Matthew’s gospel, the doxology got copied onto the page, inserted into the Gospel. Every time that ms was copied, it was copied into the new ms.
In the West, St Jerome’s Vulgate did not have this doxology after the Lord’s prayer. It was not in the mss he worked with, not even the Greek ones. The Vulgate became the standard, and the West largely forgot about Greek. Not until Aristotle was reintroduced in the 12-13th centuries, from the Arab world, was Greek studied in the West.
This meant that Greek mss, the Byzantine text type, were the dominant source for the original language of the NT. When Erasmus compiled the Textus Receptus, the Greek NT used at the time of the Reformation, the majority of his texts were Byzantine so he included the doxology in his critical text. The most up to date scholarship said it was part of the prayer.
A few hundred years later, it became clear that some mss never had the doxology. They became known as the Alexandrian text type, because they were found or came from Alexandria in Egypt, more or less. There were fewer of these since North Africa was conquered by Muslims in the 7th century. This also meant they tended to be older, less frequently copied. These were acknowledged as closer to the source text, and are preferred for many differences. Now the most up to date scholarship said the doxology should not be included.
This is how it stands today. Some people follow the up to date scholarship of the 1500s. The rest of us follow that of the 18-19th centuries. And few of us know why we disagree when we pray the most basic prayer in our traditions.