NAND output is one if atleat one input is 0
OR output is 1 when atleast 1 input is 1
when control signal is 0
Top NAND will be 1 OR will be $OR(0,A,B)=OR(A,B)$ resulting in
$NAND(1,A+B)=\overline{A+B}=\overline{A}.\overline{B}$
when control input is 1 top NAND will give $\overline{A.B}$
OR will give 1 (or is 1 when atleast 1 is 1)
finally give $\overline{\overline{A.B}.1}=\overline{\overline{AB}}+0=AB$