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$.
Best Answer
$\require{AMScd}$ There is a retraction of $D^n\times I\twoheadrightarrow D^n×\{0\}\cup S^{n-1}×I$ defined via $$r(x,t)=\begin{cases} \left(\frac{2x}{2-t},\ 0\right) &\text{, if }t\le2(1-||x||) \\ \left(\frac x{||x||},2-\frac{2-t}{||x||}\right)&\text{, if }t\ge2(1-||x||) \end{cases}$$ It is easy to prove that this map is well-defined and continuous and a retraction. Then $$d:D^n×I×I\to D^n×I\\ d(x,t,s)=sr(x,t)+(1-s)(x,t)$$ is a homotopy between the identity and $r$, so $r$ is a deformation retraction. But then $(D^n×I)\cup_H X$ deformation retracts onto $(D^n×\{0\}\cup S^{n-1}×I)\cup_H X=(D^n×\{0\})\cup_f X$
Note that a pushout square ($A,X$, and $B$ are arbitrary spaces)
\begin{CD} A @>f>> B\\@ViVV @VV\tilde iV\\ X @>>\tilde f> X\cup_f B \end{CD} gives rise to a pushout square \begin{CD} A\times I @>f>> B \times I\\@ViVV @VV\tilde iV\\ X\times I @>>\tilde f> (X\cup_f B)\times I \end{CD}
because the quotient map $q:X\sqcup B\to X\cup_f B$ induces a quotient map $q\times 1:X\times I\sqcup B\times I\to(X\cup_f B)\times I$.
This means that a pair of homotopies $F_t:X→Y$, $G_t:B→Y$, such that $F_ti=G_t f$ for all $t\in I$, induces a homotopy $H_t:X∪_f B→Y$
That's the reason why a deformation retraction on $D^n×I$ induces a deformation retraction on the pushout $(D^n×I)\cup_F X$
There is more general result: If $(X,A)$ is cofibered, then $X×I$ deformation retracts to $X×\{0\}\cup A×I$, so if $X$ is glued via two homotopic maps $f$ and $g$ to a space $B$, then $X\cup_f B$ and $X\cup_g B$ are homotopy equivalent.