Question:
Show that $D^n \times [0,1] \times \{0\} \cup S^{n-1} \times [0,1] \times [0,1]$ is a retract of $D^n \times [0,1] \times [0,1]$.
Attempt: I have proved a more intuitive retraction, namely $r : D^n \times [0,1] \to D^n \times \{0\} \cup S^{n-1} \times [0,1]$ given by $$r(x,t) = \begin{cases}\qquad\>\>\,\, \left(\frac{2x}{2-t}, 0\right), &\|x\| \leq 1 - \frac{t}{2} \\ \left( \frac{x}{\|x\|}, 2 - \frac{2-t}{\|x\|}\right), &\|x\| \geq 1 - \frac{t}{2}\end{cases}$$(see Figure). 
Now considering $\tilde r : = r \times id : Y \times [0,1] \to A \times [0,1]$, where $Y = D^n \times [0,1]$ and $A = D^n \times \{0\} \cup S^{n-1} \times [0,1]$ one finds easy to see that $\tilde r $ is a continuous map and for any $(a,t) \in A \times [0,1]$ we have $$\begin{aligned}\tilde r (a,t) & = (r \times id )(a,t)\\&= (r(a), t) = (a,t)\end{aligned}$$ Thus $\tilde r|A \times [0,1] = id_{A \times [0,1]}$.
$1)$ Is it correct?
It's incorrect since $D^n \times \{0\} \times [0,1] \neq D^n \times [0,1] \times \{0\}$.
Here is what I think is a solution:
Claim: One can show more generaly that if $r : X \to A$ is a retraction then so is $\tilde r : X \times Z \to A \times Z$, for any space $Z$.
in order to show this we make use of a Lemma.
Lemma: $A$ is a retract of $X$ iff, for every space $Y$, any continuous map $G : A \to Y$ has a continuous extension $f : X \to Y$.
Proof: (skecth) Suppose $A$ is a retract of $X$. Define $f : g \circ r$, where $r : X \to A$ is a retraction and $g : A \to Y$ a continuous map. Conversely, choose $Y = A$ and $id : A \to A$.
Proof of Claim: Let $Y = (X \times Z) \times \{0\} \cup (A \times Z) \times [0,1]$ and $A = X \times \{0\} \cup A \times [0,1]$. Then by the Lemma above there exists a continuous extension $f : X \times [0,1] \to Y$ of $g : A \to Y$ with $f|A = g$, where $g$ is given by
$$g(a,t) = \begin{cases}(id \times \iota \times \{0\}) \circ (id \times \{z\} \times \{0\})(a,t) , &\text{if} \ \ (a,t) \in X \times \{0\}\\ \quad\ (id \times \iota \times id )\circ (id \times \{z\} \times id)(a,t), &\text{if} \ \ (a,t) \in A \times [0,1]\end{cases}$$ where $\iota : \{z\} \to Z$ is the inclusion map. Since in $X \times \{0\} \cap A \times [0,1] = A \times \{0\}$ both $(id \times \iota \times \{0\}) \circ (id \times \{z\} \times \{0\})$ and $(id \times \iota \times id )\circ (id \times \{z\} \times id)$ agree then by the Gluing Lemma $g$ is continuous.
The retraction wanted is then given by the composition $$\tilde r : (X \times Z) \times [0,1] \overset{pr_1 \times id}\longrightarrow X \times [0,1] \overset{f}\longrightarrow Y$$ which is continuous and $\tilde r|Y = id_Y$