The lemma and a part of its proof are given below:
Now, I was trying to prove the other part $ g \circ f \simeq g \circ h$.
My trial:
Suppose $f,h : X \rightarrow Y$ are homotopic, and $g: Y \rightarrow Z.$
Let $H: X \times I \rightarrow Y$be the homotopy from $f$ to $h$.
Define $F: Y \times I \rightarrow Z$ by:
$$F(y, t) = G(H(x,t),t)$$
Then $F(y,0) = G(H(x,0),0) = G(h_{0}(x),0) = G (f(x),0) = g_{0}(f(x)) = g \circ f$
I am not sure if my last equality correct as I replaced $g_{0}$ by $g$ without having any clue about this, is this step true?
Also, should the function $G$ be known, as I do not know anything other than that $G(x,t) = g_{t}(x)$?
Any help with the proof will be appreciated. Also, any correction for my trial steps is so much welcomed.
Thanks!

The idea here is that you want to construct a function $X \times I \to Z$, and you have functions $X \times I \to Y$ and $Y \to Z$. The "obvious" (in retrospect) thing to do is to simply compose the functions, which indeed is correct!
Let $H : X \times I \to Y$ be the homotopy from $f$ to $h$ and let $g : Y \to Z$. Define $F = g \circ H$. $F$ is continuous because it is the composition of two continuous functions, and we see that $$F(x,0) = g(H(x,0)) = g(f(x)) = (g \circ f)(x)$$ while $$F(x,1) = g(H(x,1)) = g(h(x)) = (g \circ h)(x).$$ Thus, $F$ is a homotopy from $g \circ f$ to $g \circ h$.