\((\Rightarrow)\) Write
\(L = (X \times \{0\}) \cup (A \times I)\) and apply the HEP to the target
\(Y = L\text{,}\) with
\(f = i_0 \colon X \to L\text{,}\) \(x \mapsto (x,0)\text{,}\) and
\(H = i \times \mathrm{id}_I \colon A \times I \to L\text{,}\) which is nothing but the inclusion of
\(A \times I\) as one of the two pieces of
\(L\text{.}\) These agree on
\(A \times \{0\}\text{,}\) so the HEP provides a filler
\(\widetilde{H} \colon X \times I \to L\) with
\(\widetilde{H}(x,0) = (x,0)\) for all
\(x \in X\) and
\(\widetilde{H}(a,t) = (a,t)\) for all
\((a,t) \in A \times I\text{.}\) Every point of
\(L\) is of one of these two forms, so
\(\widetilde{H}\) restricts to the identity on
\(L\text{;}\) as its codomain is already
\(L\text{,}\) it is a retraction.
\((\Leftarrow)\) Suppose
\(A\) is closed in
\(X\) and
\(r\) is such a retraction. Then any maps
\(f \colon X \times \{0\} \to Y\) and
\(H \colon A \times I \to Y\) agreeing on
\(A \times \{0\}\) assemble into a continuous map
\(f \cup H \colon (X \times \{0\}) \cup (A \times I) \to Y\) (here we use that
\(A\) is closed, so that
\(X \times \{0\}\) and
\(A \times I\) are closed subsets and the pasting lemma applies), and
\((f \cup H) \circ r\) is the required extension. For the general case, see Hatcher, Proposition A.18.