While markets are far from perfect, this does seem to be a problem capitalism can and will solve. Companies need to attract talent - engineers will vote with their feet if this is important to them. And, companies need to perform - if WFH truly doesn't work it will become apparent very soon (or conversely, if it works far better than in-office, the next crop of world class companies will all be remote).
One thing that is relatively undisputed common knowledge is that company culture and norms become ever more critical as a team scales. The startups and companies that navigate this the best will likely be highly intentional about whatever path they take, and both new and existing employees will be naturally repelled/attracted based on how much this suits them.
This should be a good thing. You, as an employee, get to pick whichever one you want. Just ask questions so you know what you are getting into.