The fact that the NAND (not-and) gate is a universal gate in electronics is incredibly useful because it enables you to build any logic circuit, simple or complex, by using just NAND gates.
When you begin to build your own digital circuits, you can stock up on integrated circuits that contain just NAND gates and be assured that you can build even the most complex circuits with your stock of NAND gates.
NOT: You can create a NOT gate from a NAND gate simply by tying the two inputs of the NAND gate together.
Because the two inputs of the NAND gate are tied together, only two input combinations are possible: both HIGH or both LOW. If both inputs are HIGH, the NAND gate will output a LOW. If both inputs are LOW, the NAND gate will output HIGH. Thus, the circuit behaves exactly as a NOT gate would.
AND: You can create an AND gate by using two NAND gates. The first NAND gate does what NAND gates do: returns LOW if both inputs are HIGH and returns HIGH if both inputs are anything else. Then the second NAND gate is configured as a NOT gate to invert the output from the first NAND gate.
One of the basic rules of NOT gates is that if you invert a signal twice, you end up with the same signal. If the original input is HIGH, and you invert it, the signal becomes LOW. Invert the input again, and it returns to HIGH. With this rule in mind, you should be able to see how the two NAND gates work together to create an AND gate.
OR: You need three NAND gates to create an OR gate. First, you use a pair of NAND gates configured as NOT gates to invert the two inputs. Then the third NAND gate produces a LOW output if both of the original inputs are LOW. If one of the original inputs is HIGH, or if both of the original inputs are HIGH, the output of the third gate is HIGH.
NOR: It takes four NAND gates to create a NOR gate. This circuit is the same as the OR gate circuit, with the addition of another NOT gate to invert the output from the third NAND gate. Inverting the output changes the overall function of the circuit from OR to NOR.