Progression of Halakhah Using Chanukah
וּמִפֶּתַח֩ אֹ֨הֶל מוֹעֵ֜ד לֹ֤א תֵֽצְאוּ֙ שִׁבְעַ֣ת יָמִ֔ים עַ֚ד י֣וֹם מְלֹ֔את יְמֵ֖י מִלֻּאֵיכֶ֑ם כִּ֚י שִׁבְעַ֣ת יָמִ֔ים יְמַלֵּ֖א אֶת־יֶדְכֶֽם׃

You shall not go outside the entrance of the Tent of Meeting for seven days, until the day that your period of ordination is completed. For your ordination will require seven days.

We learn in Leviticus it takes seven days to ordain a priest or to consecrate something and to make it holy. (The Torah was compiled ca. 4th Century BCE)

כשנכנסו יונים להיכל טמאו כל השמנים שבהיכל וכשגברה יד בית חשמונאי ונצחום בדקו ולא מצאו אלא פך אחד שהיה מונח בחותמו של כהן הגדול שלא נטמא ולא היה בו להדליק אלא יום אחד ונעשה בו נס והדליקו ח' ימים. לשנה אחרת קבעו ח' י"ט. ומה ראו לעשות חנוכה ח' ימים והלא חנוכה שעשה משה במדבר לא עשה אלא שבעה ימים שנא' ומפתח אהל מועד לא תצאו שבעת ימים וגו' ואומר ויהי המקריב ביום הראשון את קרבנו וגו' ובשביעי הקריב אפרים. וכן מצינו בחנוכה שעשה שלמה שלא עשה אלא שבעת ימים שנא' כי חנוכת המזבח עשו שבעת הימים והחג ז' ימים ומה ראו לעשות חנוכה זו ח' ימים אלא בימי מלכות יון נכנסו בית חשמונאי להיכל ובנו את המזבח ושדוהו בשיד ותקנו בו כלי שרת והיו מתעסקין בו ח' ימים. ומה ראו להדליק את הנרות אלא בימי מלכות יון שנכנסו בית חשמונאי להיכל שבעה שפודין של ברזל בידם וחפום בעץ והדליקו בהם את המנורה. ומה ראו לגמור בהם את הלל אלא שכל תשועה ותשועה שהקב"ה עושה להם לישראל היו מקדימין לפניו בהלל בשירה ובשבח ובהודאה כענין שנא' ויענו בהלל ובהודו לה' כי טוב וגו' מצות חנוכה נר איש וביתו והמהדרין נר לכל נפש ונפש והמהדרין מן המהדרין בש"א יום ראשון מדליק שמונה מכאן ואילך פוחת והולך ובה"א יום ראשון מדליק א' מכאן ואילך מוסיף והולך. שני זקנים היו בצידן אחד עשה כדברי ב"ש ואחד עשה כדברי ב"ה זה נותן טעם לדבריו וזה נותן טעם לדבריו זה אומר כפרי החג וזה אומר מעלין בקודש ואין מורידין. מצות הדלקתה משתשקע החמה עד שתכלה רגל מן השוק ומצוה להניחה על פתח ביתו מבחוץ ואם היה דר בעליה מניחה בחלון הסמוכה לרה"ר ואם מתירא מן הלצים מניחה על פתח ביתו מבפנים ובשעת הסכנה מניחה על שלחנו ודיו:

And what justification did they see for making Channuka eight days? Wasn’t the dedication (channuka) which Moshe did in the wilderness only seven days? ... So what reason did they see to make this dedication eight days? In the days of the kingdom of Greece the Hasmoneans entered the Temple, built the altar, plastered it with plaster [which took a day] and for seven days they were preparing the vessels for service.

The Tannaim (earlier ancient rabbis) made reference back to the Torah and wondered why Chanukah is eight days instead of seven days. It took an eighth day for the Temple to be purified and dedicated back to God in the account of Chanukah which is why Chanukah is eight days. (The commentaries in the Mishna are believed to date back ca. 2nd Century CE)

תנו רבנן מצות חנוכה נר איש וביתו והמהדרין נר לכל אחד ואחד והמהדרין מן המהדרין בית שמאי אומרים יום ראשון מדליק שמנה מכאן ואילך פוחת והולך ובית הלל אומרים יום ראשון מדליק אחת מכאן ואילך מוסיף והולך

The Sages taught in a baraita: The basic mitzva of Hanukkah is each day to have a light kindled by a person, the head of the household, for himself and his household. And the mehadrin, i.e., those who are meticulous in the performance of mitzvot, kindle a light for each and every one in the household. And the mehadrin min hamehadrin, who are even more meticulous, adjust the number of lights daily. Beit Shammai and Beit Hillel disagree as to the nature of that adjustment. Beit Shammai say: On the first day one kindles eight lights and, from there on, gradually decreases the number of lights until, on the last day of Hanukkah, he kindles one light. And Beit Hillel say: On the first day one kindles one light, and from there on, gradually increases the number of lights until, on the last day, he kindles eight lights.

The Amoraim (later ancient rabbis) used what was stated in the Mishna to create Halacha on how we should light candles at home to mark Chanukah. (The Gemara portion of the Talmud is believed to have been compiled ca. 7th Century CE)

כמה נרות מדליק בלילה הראשון מדליק אחד מכאן ואילך מוסיף והולך אחד בכל ליל' עד שבליל אחרון יהיו שמונ' ואפי' אם רבים בני הבית לא ידליקו יותר: הגה וי"א דכל אחד מבני הבית ידליק (רמב"ם) וכן המנהג פשוט ויזהרו ליתן כל א' וא' נרותיו במקום מיוחד כדי שיהיה היכר כמה נרות מדליקין [מהר"א מפראג]:
How many lights should one kindle? On the first night, he kindles one [light]. From then on he continues to add one each night, until on the last night they are eight. And even if the household members are many, they should not kindle more. Rem"a: And some say that every one of the household members kindles (Maimonides) and such is the widespread custom. And they should take care to each place their lights in a unique place, so that it will be apparent how many lights they are kindling. (Abraham Kara of Prague)

By the time we get to the Shulchan Arukh, the Halacha is more clear about how many candles to light each night of Chanukah. (Authored ca 16th Century)