State and local governments borrowed nearly $9 billion for affordable housing so far this year — the most for the period in at least a decade — as buying a home in the US remains expensive.