These circuits are made with diodes or bipolar transistors. Let us take as an example the realization of the 3 basic logical operators.

Realization of the AND:

Operation: Let us consider that the 1 corresponds to the voltage Vcc (5V for example), and the 0 to the mass: GND (ground) = 0V.

if A = B = 0 then the 2 diodes are forward biased => They are conducting => in Y, we have 0.6V or approximately 0V => Y = 0.

if A = 1, B = 0 then D1 is reverse biased => D1 is blocked. On the other hand, D2 is forward biased => D2 is conductive and imposes in Y: 0.6V (approximately 0V) => Y = 0.

if A = 0, B = 1 then symmetrically to the previous case, we have D2 blocked and D1 open => Y = 0.

if A = B = 1 then the 2 diodes are reverse biased => in Y we have about Vcc => Y = 1.