According to Torah law, every Yom Tov is exactly one day. Indeed, this is the practice in Eretz Yisrael on every Yom Tov but Rosh Ha-shana. However, in the Diaspora the Sages ordained that an additional day be celebrated, so that instead of one day of Yom Tov, there are two. The second day is referred to as Yom Tov Sheni Shel Galuyot (the extra day of Yom Tov observed in the Diaspora).
In order to understand the origin of this halakha, some background information is necessary. All of the Jewish holidays have a set date in the Jewish calendar. The first day of Pesaḥ is on the 15th of Nisan, and its seventh day is on the 21st of Nisan. Shavu’ot is at the conclusion of the omer period which begins on the 16th of Nisan. Rosh Ha-shana is on the first of Tishrei, while the first day of Sukkot is on the 15th, and Shemini Atzeret is on the 22nd. Since the Jewish month is based on the lunar cycle, and each cycle takes a bit longer than twenty-nine and a half days, some months have thirty days (malei, lit. “full”) and others have twenty-nine (ḥaser, or in technical terms, “hollow”). The mitzva was for people who saw the new moon (that is, the first vision of the moon after the molad, or lunar conjunction) on the eve of the 30th of the month to come and testify before the beit din. The new month would then be sanctified based on their testimony. This is the meaning of the verse: “This month shall mark for you the beginning of the months” (Shemot 12:2). The Sages explain: “God showed Moshe the form of the new moon and said, ‘Testifying to this has been placed in your hands’” (RH 22a). “Your hands” refers to those of judges with ordination, which was transferred in an unbroken chain from the time of Moshe (see Peninei Halakha: Zemanim 1:1-2).
After the month was sanctified, messengers would depart to all parts of Eretz Yisrael to spread the news, so that they would know when to celebrate the upcoming holiday (RH 21b). However, the messengers were unable to reach Diaspora communities before the holiday. Therefore, by the time of the early prophets, there were already standing instructions for the Diaspora to keep each holiday for two days on account of the uncertainty about the date. This was what Yeḥezkel and Daniel did. It is possible that the practice goes back as far as Yehoshua bin Nun (R. Hai Gaon in Otzar Ha-Ge’onim, Yom Tov 4:2).