In this paper on the modular exponentiation function of Shor's Algorithm the author mentions creating a special circuit that decomposes the function $f(x)=a^x \mod N$ into
$$(...((a^{x_02^0} \mod N) \times a^{x_12^1} \mod N) \times ...) \times a^{x_{n-1}2^{n-1}} \mod N$$
inspired by other papers and Nielsen and Chuang Box 5.2, breaking up one modular exponentiation into a bunch of modular multiplications. So far, I understand this decomposition. Then, a new function $g(y) = (y \times a) \mod N$ is created an is used to mimic the nature of the modular exponentiation. For example: $$(y \times 21^2) \mod 143 = g(g(y)).$$ Next, a truth table is constructed, and a circuit is designed based on the truth table values. For example, my question is: does the circuit for this function merely check the values of the possible inputs listed in the truth table and transform them? if so, why does it work compared to the arithmetic computations seen in most approaches (e.g., example).
