As affordable housing disappears, states scramble to shore up the losses