On the following website the author is explaining the Cartesian product as:
The set $X \times Y$ can be identified with the set of functions defined on the two-element set $\{1,2\}$ and taking the value $1$ to elements of $X$, and the value $2$ to elements of $Y$.
What does this mean exactly, what is this set of functions defined on $\{1,2\}$? Can anyone interpret this?
Identify a point $(x,y) \in X \times Y$ with a function $f: \{1,2\} \to X \cup Y$ defined by $f(1)=x, f(2)=y$.
And if we have a function $f: \{1,2\} \to X \cup Y$ obeying the conditions that $f(1) \in X$ and $f(2) \in Y$, we associate this $f$ to the pair $(f(1), f(2)) \in X \times Y$.
These identifications are each other's inverse. So the sets $X \times Y$ and $$ \{f: \{1,2\} \to X \cup Y \mid f \text{ a function and } f(1) \in X, f(2)\in Y \}$$ are in a bijective relation and can be trivially identified. This then sets the stage for larger (and infinite) products and powers etc.