Tens of billions of dollars’ worth of apartment building loans and mortgages are at risk of distress as of the end of the second quarter.