Forcing developers to build affordable housing (and by forced it obviously means not economically feasible to do so) you are increasing costs which makes them focus only on luxury housing to support the additional costs.
From an economic theory standpoint, forcing developers to build affordable housing is dumb. You are implicitly taxing on activity you want more of: building market rate housing. It would be better to fund affordable housing out of a general revenues or better yet a tax on NIMBY neighborhoods that restrict new construction.
But from a practical political standpoint, requiring builders to include affordable housing has 2 benefits: 1) politically it builds support for new housing construction and 2) it (albeit inefficiently) provides funding for new construction via an backdoor tax that is too abstract for most voters to realize(and by extension oppose).
I'm no political scientist, but I would imagine an inefficient but tangible policy will beat our efficient but abstract policy every time.