Are you familiar with how typical ALUs set flags to indicate that overflow occurred, or that the result of an operation is zero or negative? Typically, a comparison is performed by doing a subtraction and updating the flags but discarding the numerical result.
For example, if you subtract 7 from 5, the result is negative. Therefore, 5 is less than 7.
I should note that this is definitely not the only way in which it is possible to implement comparison. With a little thought, one can construct an algorithm (which could be made into a circuit) to directly compare the binary representations of two integers without subtracting them. However, subtraction is such a fundamental operation that (almost) all CPUs implement it quite efficiently already, and there is no reason not to reuse that implementation for comparisons.