Question about retracts of the unit square and continuous extensions.

Recently, I have been reviewing previous exam questions that I missed. The following question has been giving me some issues for quite some time, and I was wondering if anyone would help me out. The question is as follows:

Let $X$ be a closed subset of the square $I^2 = [0,1] \times [0,1]$. Then, the following are equivalent:

(1.) $X$ is a retract of $I^2$, i.e., there is a mapping $r$ of $I^2$ onto $X$ which is the identity on $X$;

(2.) If $Y$ is a normal space and $A$ is a closed subset of $Y$, then every continuous function $f:A \rightarrow X$ has a continuous extension $\overline{f}:Y \rightarrow X$.

Thanks again for everything!

-

(2) implies (1) is easy: take $Y = I^2$, $A = X$, and then the identity map $f:X \to X$ extends to $r:I^2 \to X$. By definition, this is the identity on $X$, so it's a retraction. (The 'onto' part comes for free.)
For the other direction, note that (2) works for $X = I^2$, then it works for any retract of $I^2$. Indeed, given $f:A \to X$ for $X$ a retract of $I^2$, composition with the inclusion map gives a map $A \to I^2$, and by assumption this extends to $Y \to I^2$. Now composing with the retraction gives a map $\bar{f}:Y \to X$. Since the map $A \to I^2$ maps $A$ into $X$, and the retraction fixes these points, $\bar{f}$ actually extends $f$.
You should think of '$A$ is a retract of $B$' as a statement that's designed to let you make arguments like the one above. The above argument doesn't really use any topology, and you can actually make similar arguments with other things besides topological spaces -- for example, the equivalent idea for abelian groups is '$A$ is a direct summand of $B$'.
Now, however, we have to actually use topology to prove that (2) holds for $I^2$. For this you need the Tietze extension theorem. The map $f:A \to I^2$ induces two maps $f_1,f_2:A \to \mathbb{R}$ by projecting onto the two coordinates, and including into $\mathbb{R}$. By the Tietze extension theorem, these extend to maps $g_1, g_2:Y \to \mathbb{R}$, and we get a map $g:Y \to \mathbb{R}^2$ defined by $g(x) = (g_1(x), g_2(x))$, which clearly extends $f$.
Unfortunately, this might not land in $I^2$. Fortunately, $I^2$ is a retract of $\mathbb{R}^2$! For example, we could draw a line from every point $x$ in $\mathbb{R}^2$ outside the square to the center of the square, and send $x$ to the point where this line intersects the boundary of the square. Composing $g$ with this retraction gives $\bar{f}:Y \to I^2$. Since the original $f$ landed in $I^2$, this map extends $f$.