More than a fifth of New York City’s core affordable housing stock is in the red or close to it — putting tenants at risk.