It's simpler to just think of the yield to maturity as the internal rate of return of the bond given the current price. It's like the discount rate you would apply to the final payout and coupons, such that the result is the market price.
A short paper by Forbes, Hatem, and Paul explains that yield to maturity ignores reinvestment. Strictly speaking, yield to maturity is an internal rate of return, not the return you would get at the horizon. The return you get at the horizon depends on the reinvestment policy. The return at the horizon only matches the yield to maturity if the coupons are invested at the same yield as the yield to maturity.
For instance, assume a \$1000 bond with \$50 annual payments and 2 years until maturity and a 10% yield to maturity. The current price is \$913.22. The sum of the return and the coupons is \$1100. Ignoring reinvestment, the return at the end of two years is 20% cumulatively (1100 / 913.22 - 1) or 9.75% annualized. However, if the \$50 from year 1 is re-invested at a 10% rate, then the investor would now have $1105, generating a 21% return cumulatively (1105 / 913.22 - 1) or 10% annualized.
Long story short, the yield to maturity is a bond's internal rate of return given its current price. It is only the return you would earn if you held the bond to maturity if you reinvest at that same rate.