(N/A) In both the given circuits,$A$ and $B$ are the inputs and $Y$ is the output.
$(a)$ The output of the first $NAND$ gate is $\overline{A \cdot B}$. This output is fed into a second $NAND$ gate where both inputs are connected together. $A$ $NAND$ gate with both inputs connected acts as a $NOT$ gate. Therefore,the final output is $Y = \overline{(\overline{A \cdot B})} = A \cdot B$. Hence,this circuit functions as an $AND$ gate.
$(b)$ In this circuit,the first two $NAND$ gates have their inputs connected together,so they act as $NOT$ gates. The outputs are $\overline{A}$ and $\overline{B}$ respectively. These are then fed into a third $NAND$ gate. The final output is $Y = \overline{\overline{A} \cdot \overline{B}}$. By De Morgan's theorem,$\overline{\overline{A} \cdot \overline{B}} = \overline{\overline{A}} + \overline{\overline{B}} = A + B$. Hence,this circuit functions as an $OR$ gate.