Problems of the general definition of Cartesian product The usual definition of an arbitrary Cartesian product is: if $\{X_i\}_{i \in I}$ is an indexed family of sets, $\prod_{i \in I}X_i$ is defined to be the set of all functions $x:I \rightarrow \bigcup_{i \in I} X_i$ such that $x(i) \in X_i$ for all $i\in I$. But I believe that this definition cause some intuitive properties of the product to be false.
The main problem is that, every time $\{ X_i\}_{i\in I}$ and $\{ Y_i\}_{i\in I}$ are distinct families such that $\bigcup_{i \in I} X_i \neq \bigcup_{i \in I} Y_i$, then, rigorously, no function of the form $x:I \rightarrow \bigcup_{i \in I} X_i$ can be of the form $x:I \rightarrow \bigcup_{i \in I} Y_i$, because for two functions to be the same, they must have the same Codomain. This observation shows that, in this case, $(\prod_{i\in I} X_i) \bigcap (\prod_{i\in I} Y_i)= \emptyset$, and a consequence of this is that:
$$X_i \subseteq Y_i \ \ \forall i \in I \not \Rightarrow \prod_{i \in I} X_i \subseteq  \prod_{i \in I} Y_i$$
(you can see this if you let the $X_i$ be proper subsets of the $Y_i$, for example).
I acknowledge that this problem is usually ignored for practical purposes, but I would like to know if there is a way of fixing this by changing something in the definition of the product (or if I am making any mistakes in my reasoning). Thanks in advance.
 A: 
for two functions to be the same, they must have the same Codomain

This presupposes a particular notion of "function" which is not the one used in set theory. In set theory, a function is defined as a set of ordered pairs - with no explicit codomain. Phrased another way, there is no difference between a function $f$ and its graph $\{\langle a,b\rangle: f(a)=b\}$.
And it's this set-theoretic definition of "function" which is used when $\prod_{i\in I}X_i$ is defined as "the set of functions with domain $I$ and codomain $\bigcup_{i\in I}X_i$ sending each $i\in I$ to some element of $X_i$."

Of course, having an explicit codomain can be quite useful. So we can also talk about more complicated objects, pairs $\langle f, A\rangle$ where $f$ is a function in the above "weak" sense and $A$ is some set containing each right coordinate of an element of $f$ (a valid choice of codomain). In set theory there isn't a special term for these, since the "codomain-free" definition is generally more useful, but I've heard terms like "function-with-codomain" used here. But when we use the appropriate definition of function, the issue you point to does not arise.
