I was wondering if someone would not mind proofreading my demonstration for the following problem. Any sentences in brackets [] will be omitted in the formal proof.
Problem
Let $B$ be a set, let $A_1, \dotsc, A_n$ be sets for some $n \in \mathbb{N}$ and let $h_i : B \rightarrow A_i$ be a function for each $i \in \{1,\dotsc,n\}$. Prove that there is a unique function $g:B\rightarrow A_1 \times \cdots \times A_n$ such that $\pi_i \circ g = h_i$ for all $i \in \{1,\dotsc, n\}$ where $\pi_i:A_1 \times \cdots A_n \rightarrow A_i$ is the projection map.
Proof
Existence
Set $I$ to be an indexing set such that $I = \{1,\dotsc,n\}$ for some $n \in \mathbb{N}$.
Let $h_i:B \rightarrow A_i$ for each $i \in I$. Let $b \in B$. Iterating through the values of $i$, we have a sequence of images $h_1(b), \dotsc, h_n(b)$. If the set $A_1 \times \dotsc \times A_n$ is a Cartesian product for each $A_i$, then the $n$-list $(h_1(b), \dotsc, h_n(b)) \in A_1 \times \dotsc \times A_n$. Thus, we have an ordered pair $(b,(h_1(b), \dotsc, h_n(b)))$. Define the relation $g:B \rightarrow A_1 \times \dotsc \times A_n$. Then $(b,(h_1(b), \dotsc, h_n(b))) \in g$.
To prove that $g$ is a function, we first note that for every $b \in B$, the function $h_i$ gaurantees the (unique) existence of an image $(h_1(b),\dotsc,h_n(b)) \in A_1 \times \dotsc \times A_n$. To prove uniqueness, let the images $x = g(b)$ and $y = g(b)$ for each $b \in B$ such that $x \neq y$. Thus, the n-lists $x = (h_1(b),\dots, h_n(b))$ and $y = (h_1(b),\dotsc, h_n(b))$ have at least one differing component $j$ where we denote $h_j(b)$ to be the $j^{th}$-component of $x$, and $h^*_j(b)$ to be the $j^{th}$ componenet of $y$. Therefore, $h_j(b) \neq h^*_j(b)$. But this implies that $h_j$ is not a function for an arbitrary $j \in I$, which is a contradiction.
Hence, $g$ is a function.
Now construct the composition $\pi_i \circ g: B \rightarrow A_i$. We will prove that $\pi_i \circ g = h_i$.
We first note that the domain and codomain of $\pi_i \circ g$ and $h_i$ are equal by construction.
We now prove that for all $b \in B$, we have $h_i(b) = \pi_i(g(b))$ for all $i \in I$
Choose any $m \in I$.
First, let $b \in B$. Then $h_m \in A_m$. By definition of $\pi_i \circ g$, the fact that $h_m \in A_m$ for an arbitrary $m \in I$ implies that $(b,h_m(b)) \in \pi_i \circ g$, so $h_i \subseteq \pi_i \circ g$.
Now, since we are assuming that $b \in B$, we have $g(b) \in A_1 \times \dotsc \times A_n$. Then applying $\pi_m$ to $g$, we deduce that $\pi(g(b)) \in A_m$. By definition of $h$, we must have $(b, \pi_m(g(b))) \in h_m$. Therefore, $\pi_i \circ g \subseteq h_i$.
We conclude that $\pi_i \circ g = h_i$ for each $i \in I$.
Uniqueness
Suppose to the contrary that there are two functions $g:B\rightarrow A_1 \times \dotsc \times A_n$ and $g':B\rightarrow A_1 \times \dotsc \times A_n$ such that $h_i = \pi_i \circ g$, $h_i = \pi_i \circ g'$ for all $i \in I$, and $g(b) \neq g'(b)$ for some $b\in B$ [This implies that some of the components of $g(b)$ and $g'(b)$ are not equal; recall that $g(b) \in A_1 \times \dotsc \times A_n$, which means that the element $g(b) = (a_1,\dotsc,a_n)$ for some $a_i \in A_i$]
Let $b \in B$. For each $m \in I$, we have $h_m(b) \in A_m$. From our premise, we know that $h_m = \pi_m(g(b))$ and $h_m = \pi_m(g'(b))$. We note that we cannot have $\pi_m(g(b)) \neq \pi_m(g(b))$, because then $h_m$ would not be a function. Hence, $\pi_m(g(b)) = \pi_m(g'(b))$.
However, observe that $\pi_m(g(b))$ is an arbitrary component of the preimage $g(b)$. Thus the equality $\pi_m(g(b)) = \pi_m(g'(b))$ implies that the components of $g(b)$ and $g'(b)$ are equal, entailing that $g(b) = g'(b)$.
Hence the function $g = g'$. Therefore, there exists a unique function $g: B \rightarrow A_1 \times \dotsc \times A_n$ such that $\pi_i \circ g = h_i$ for all $i \in I$. $\blacksquare$
The proof you gave is correct. However, you only prove uniqueness where you should also prove existence. In general, when you are asked to prove that "there exists a unique" something, you have to prove that there actually exists such an object, and that it is unique.
The proof of existence is not correct. You cannot start by assuming you have such a function $g$, you must instead start with the maps $h_i$ and show that you can construct such a $g$.