The Moon’s phases repeat every 29.5 days (this is called a sidereal month), but it’s orbit around the Earth only takes 27.3 (this is called a month). Why? In that time, as our Moon moves around Earth, the Earth also moves around the Sun. Our Moon must travel a little farther in its path to make up for the added distance and complete its phase cycle.https://www.iop.org/explore-physics/moon/phases-and-orbits-moon
About the sidereal month
The period of the Moon’s orbit as defined with respect to the celestial sphere of apparently fixed stars is known as a sidereal month because it is the time it takes the Moon to return to a similar position among the stars: 27.321661 days. This type of month has been observed among cultures in the Middle East, India, and China in the following way: they divided the sky into 27 or 28 lunar mansions, one for each day of the month, identified by the prominent star(s) in them.https://www.springer.com/gp/book/9781468406429.
About the synodic month
The synodic month is the average period of the Moon’s orbit with respect to the line joining the Sun and Earth. This is the period of the lunar phases, because the Moon’s appearance depends on the position of the Moon with respect to the Sun as seen from the Earth. While the Moon is orbiting the Earth, the Earth is progressing in its orbit around the Sun. After completing a sidereal month, the Moon must move a little further to reach the new position having the same angular distance from the Sun, appearing to move with respect to the stars since the previous month. Therefore, the synodic month takes 2.2 days longer than the sidereal month. Thus, about 13.37 sidereal months, but about 12.37 synodic months, occur in a Gregorian year.
Since Earth’s orbit around the Sun is elliptical and not circular, the speed of Earth’s progression around the Sun varies during the year. Thus, the angular rate is faster nearer periapsis and slower near apoapsis. The same is so for the Moon’s orbit around the Earth. Because of these variations in angular rate, the actual time between lunations may vary from about 29.18 to about 29.93 days. The long-term average duration is 29.530587981 days (29 days 12 hours 44 minutes 2.8016 seconds).https://en.wikipedia.org/wiki/Lunar_month#Sidereal_month