Soaring home prices and high mortgage rates have pushed the median first-time buyer age to 40—the oldest on record, a new report found.