This happens on almost every single project I work on. Yesterday I lead a kickoff workshop with a new client and as usual, they think of what the user experience is like when everything goes perfectly according to plan. But once I highlighted all the things they could potentially not work as planned, the scope ballooned out with the addition of various micro-loops, extra settings, etc.
It’s no fault of the client for not identifying that full scope. It almost always takes an outsider with a fresh set of eyes to interrogate things and stretch it to its corners. And that’s one reason UX designers are so valuable.
As you’ve rightly pointed out it, involving stakeholders for feedback early and often will help uncover the unknowns unknowns as quickly as possible. It’s also useful to price the initial discovery and UX phase as a separate project and then not lock down price or timeframe of the remaining design until that full scope has been realised.