Building materials company James Hardie Industries has agreed to buy AZEK, a maker of home decking, railing and pergolas, in a cash-and-stock deal worth $8.75 billion.