Your basic approach is sound. Problem is the existence of unknown unknowns, those that only appear when you reach a later stage where these unknown unknowns decide to present themselves. Often causing an unknown amount of unknown effort requires from an unknown team member or third party. This invalidates earlier timeframes, and in worst case even the entire strategy.
How does one put a proper estimate on this? Any answer is but a wild guess.
(This is where PMs provide added value by realigning business and product teams around the new situation.)
The more experience you have the more you're used to these things happening. I don't have to know that a specific thing might go wrong but I'm used to there being some random bullshit (weird CI, library happens to be deprecated, version inconsistencies, data turns out to have a fatal flaw, licensing, whatever).
You can't plan for everything though, and you're right this is where a good PM helps.
But then again this is all just estimates. The better you can estimate the better you can plan.
How does one put a proper estimate on this? Any answer is but a wild guess.
(This is where PMs provide added value by realigning business and product teams around the new situation.)