These functions can be implemented with discrete components, but chips containing four or more gates are available cheaply, so you would probably not bother these days.
However, it is instructive to see how they work:
This is a NAND gate. Both inputs (at left) have to be high for the output to be low.
If you reversed both diodes and omitted R1, you would have a NOR gate. If either input was high, the transistor would turn on and the output would be low.
If you removed both diodes and R1, and fed the input to the left of R3, you would have an inverter, or NOT gate.