Small rules stack up

That comparison was tiny.
Two inputs. Two gates. One output.

But the important part is the shape of the work.
Start with a question the machine can answer with 1 or 0. Break it into smaller yes/no questions. Wire those questions together until the final wire means the thing you wanted to know.

That is what logic means here. Not a machine thinking like a person. Just a rule, built out of tiny yes/no questions.

Add more wires and more gates, and the same idea can compare bigger numbers. Add a different arrangement, and it can do something else entirely.