The Detroit-based company agreed to buy Mr. Cooper, one of the country’s largest mortgage firms, in a $9.4 billion all-stock ...