Okay, here is my proof which took me a while to elaborate, but I think it's correct:
Note that $(D^n,S^{n-1})$ has the homotopy extension property (HEP). The salient point of my proof is a retraction of $B\times I\times I$ onto $(A\times I\times I)\ \cup\ (B\times\{0\}\times I)\ \cup\ (B\times I\times\{0\}),$ whenever $(B,A)$ has the HEP.
For $(s,t)\in I\times I$ let $s^*(s,t)=||(s,t)-d(s,t)||/||(1,1)-d(s,t)||$. Let $r$ be the retraction of $B\times I$ onto $A\times I\ \cup\ X\times\{0\}$ with coordinates $(r_x,r_s)$, and let $d:I\times I\ \longrightarrow\ I\times\{0\}\ \cup\ \{0\}\times I$ be a retraction. Now define $R:B\times I\times I\ \longrightarrow\ (A\times I\times I)\ \cup\ (B\times\{0\}\times I)\ \cup\ (B\times I\times\{0\})$,
$(x,s,t)\mapsto(r_x(x,s^*),\ \ d(s,t)+r_s(x,s^*)\cdot[(1,1)-d(s,t)])$. It is not difficult to prove that $R$ is a well-defined retraction.
Two spaces are homotopy equivalent iff they are strong deformation retracts of a larger space, and this larger space can be chosen to be the mapping cylinder $M(g)=Y\cup X\times I$, where $(x,1)\sim g(x)$. Then you can glue $B\times I$ in a canonical way, by the map $f\times\text{Id}_I$. There are maps $X\times0\xleftarrow{\ \ r\ \ }M(f)\xrightarrow{g\circ p_X}Y$ where $r$ is a deformation retraction, meaning there is a $k:M(f)\times I\to M(f),\ k(-,1)=r,\ k(-,0)=\text{Id}_{M(f)}$, a homotopy from $r$ to the identity. The map $g\circ p_X$ is a retraction homotopic to the identity via the map $h$ such that $h(x,s,t)=(x,t+s-ts)$.
Let us define a map $K:(M(f)\cup_{f\times Id} B\times I)\times I\ \longrightarrow\ M(f)\cup_{f\times Id}B\times I$ whose restriction onto $B\times I\times I$ is defined in the following way: We have shown that $B\times I\times I$ retracts onto $A\times I\times I\ \cup\ B\times(\{0\}\times I\cup I\times\{0\})$ A map on the first term is given by $k\circ(f\times\text{Id}_I\times\text{Id}_I)$, and one on the second term by $(b,s,t)\mapsto(b,s)$. They coincide on the common domain, and so they induce a map $K':B\times I\times I\to M(f)\cup_{f\times Id}B\times I$. We then combine $K'$ with $k$ on the cylinder to obtain $K$. One can then check that this is a deformation retraction onto $X\times\{0\}\cup_{f\times 0}B\times\{0\}$.
What is left is to find a deformation retraction onto $Y\cup_{gf}B$. But this one can even be explicitly written down, and the formula is practically the same as for $h$.
You are right. Since $1_{X\times I}$ is homotopic to $\pi$, we have $\iota r\simeq \iota r\pi=\pi\simeq 1_{X×I}$, which shows that $\iota$ and $r$ are homotopy inverse to each other.
It is indeed that easy. To be honest, you can have it even easier by using the general fact that if some map $f$ and the composite $gf$ are homotopy equivalences, then the map $g$ is a homotopy equivalence as well. More precisely, if $h$ is the homotopy inverse of $gf$, then $fh$ will be the homotopy inverse of $g$, as one checks by the calculation
$$g(fh)=(gf)h\simeq 1 \\
(fh)g\simeq(fh)g(fk)=f(h(gf))k\simeq fk\simeq 1$$
where $k$ is the homotopy inverse of $f$. This also shows that $k\simeq hg$.
Setting $f:X\times\{0\}\hookrightarrow X×\{0\}\cup A×I$ and $g=\iota$, can you see what the homotopy inverses for $f$ and $\iota f:X×\{0\}\hookrightarrow X×I$ are? Actually, you already used it in your proof.
The general proof shows that $X×\{0\}\cup A×I\hookrightarrow X\times I$ is always a homotopy equivalence, though it's a deformation retract only if $(X,A)$ has the HEP.
Best Answer
We have $B\cup_{f}X$ is the deformation retraction of $X\cup M_{f}$ because we can deform the part $A\times I$. We can consider the set $X\times \{0\}\cup A\times I\cup M_{f}$ with $M_{f}$ attached to $A\times I$ on $A\times \{1\}$ side. Then this space is homotopical equivalent to $X\times{0}\cup A\times 2I\cong X\times I\cong X$ by the homotopic extension property. On other hand it is obvious that $X\times \{0\}\cup A\times I\cup M_{f}$ is homotopically equivalent to $X\cup M_{f}$. Thus we have $B\cup_{f}X\cong X$.
For your question notice that $B\cup_{f}X=X\cup [A\cup _{f}B]$, and $A\cup_{f}B$ is a deformation retraction of $M_{f}=A\times I\cup_{f}B$.