The problem with the Tavares signing for Toronto wasn't that they overpaid him. He got fair market value for a high end 1C on the UFA market at the time. The problem was that Tavares was a luxury piece for the Leafs. They already had a young, soon to be elite 1C in Matthews, as well as a future Cup-winning 2C in Kadri, plus two young 1st line wingers. Tavares took up a lot of cap space that prevented them from upgrading other parts of their roster, and he just didn't fill a critical role in their team building architecture.
And it's tough, because it's hard to argue that adding a player like Tavares to your team for free is ever something you should turn down. Tavares was available and he clearly wanted to play there, what GM could say no to that kind of player falling into their lap? But at the same time it really handcuffed them in their quest to build a good defensive corps and solve their goaltending questions. And when they had the opportunity to let one of Nylander or Marner go instead and belatedly fix it, they doubled down on their "core 4" and resigned both to blank check contracts. And again, usually when you have a player as good as Marner or Nylander coming up for a new contract the right play is to keep them at all costs. But having already made the Tavares mistake they couldn't afford to do that.