Suppose $i: A ֒\to X$ is a cofibration and $Y$ is contractible. Prove that every map $f:A \to Y$ has an extension $g:X \to Y$.
I'm wondering whether my following argument is correct. Let $H: c_{y_0}\simeq \operatorname{id}_Y$ be the homotopy which contracts $Y$ to $y_0$. Here $c_{y_0}(y)=y_0$ for every $y \in Y$.
Let $f:A \to Y$ be any map. Since $i$ is a cofibration the following diagram commutes:
$\require{AMScd}$ \begin{CD} A @>{H \circ f}>> Y^I\\ @VVV @VVV\\ X @>{\widetilde{c}_{y_0}}>> Y \end{CD}
Where $H\circ f : A \to Y^I$ i.e. the map $H(f(-),-):A \times I \to Y$ and $\widetilde{c}_{y_0}:X \to Y$ is the map $\widetilde{c}_{y_0}(x)=y_0$ for every $x \in X$.
Now since $H(f(a),0) = c_{y_0}(f(a))=y_0$ there exists a homotopy $$F:X \times I \to Y$$ with $$F(i(a),t)=H(f(i(a)),t)$$ and $$F(x,0)=\widetilde{c}_{y_0}(x)=y_0.$$
If we set $g = F(-,1)$ we have a map $g: X \to Y$ with $$g(i(a))=F(i(a),1)=H(f(i(a)),1)=f(i(a))=f(a)$$
that is $g\mid_A=f$. Is this a correct way to prove the problem?
It's almost correct. The diagram you wrote down is not quite right, I'd rather see some different notation for $H:Y\to Y^I$ (to distinguish it from the $H:Y\times I\to Y$); maybe $\hat{H}$, so that the top row is $\hat{H}\circ f$.
The diagram also commutes anyway. In fact, you need it to commute and you need to manually check that it commutes; $i$ being a cofibration has nothing to do with whether or not it commutes. What it does mean is that, if it commutes (which it does) then there exists a diagonal $X\to Y^I$ which makes both triangles commute. This is very, very different from just saying "the diagram commutes". Then by adjunction there exists an associated homotopy $F:X\times I\to Y$ which does what you want.
So I guess your proof idea is exactly right, I just disagree with the way you expressed it in writing.
I think it's also clearer to phrase it like this: by the homotopy extension property of a cofibration, we know that, since $H\circ(f\times1):A\times I\to Y$ agrees with $c_{y_0}$ on $A\times\{0\}$, there must exist an extension of $H$ to some $F:X\times I\to Y$ such that $F|_{A\times I}=H$ and $F|_{X\times\{0\}}=c_{y_0}$. Then $g:=F|_{X\times\{1\}}$ extends $f$. No diagrams needed, no adjunctions needed (and I say that as a lover of both diagrammatic reasoning and of adjunctions).