Building materials company James Hardie Industries has agreed to buy AZEK, a maker of home decking, railing and pergolas.