Let $X,Y,Z$ be topological spaces, $f\colon X\rightarrow Z$ and $g\colon Y\rightarrow Z$ be continuous functions, and $Z$ be contractible. Can $f$ and $g$ be homotopic?
Note that, we know that the continuous functions $f,g\colon X\rightarrow Y$ are homotopic if $Y$ is contractible. Can we use the diagram below to answer the above question?

Note that by definition two functions can only be homotopic if they have the same domain and codomain. In your case $f$ and $g$ have the same codomain but different domains, so it doesn't make sense to ask if they are homotopic.
However if you pick an $h\colon X \to Y$ it now makes sense to compare $f$ and $g\circ h$, as they are both functions from $X$ to $Z$. Since $Z$ is contractible, we in fact have that $f\sim g\circ h$ for any $h$.