Facing a lawsuit over deceptive mortgage practices, Bank of America has agreed to modify tens of thousands of loans to keep people in Illinois, Washington and nine other states from losing their homes, the Illinois attorney general's office said Sunday.