With thousands of buildings torn down every year, nonprofits and city agencies are racing to record the stories attached to historic structures before they’re dismantled and sold for parts.