I am trying to understand Hatcher's argument as to why the binary operation on the homotopy classes paths is associative, where we define $[f][g] = [f \cdot g]$ with $f \cdot g$ is the concatenation of two paths sharing an endpoint. He argues that $(f \cdot g) \cdot h$ is a reparametrization of $f \cdot (g \cdot h)$ with $\phi$ as the piecewise linear function shown in the figure below:
I have tried to write out the explicit formulations for $f \cdot (g \cdot h), (f \cdot g) \cdot h),$ and $\phi$ as follows:
$$ ((f \cdot g) \cdot h) (s) = \begin{cases} f(4s), & 0 \leq s \leq \frac{1}{4}\\ g(4s-1), & \frac{1}{4} \leq s \leq \frac{1}{2} \\ h(2s-1), & \frac{1}{2} \leq s \leq 1. \end{cases} $$
$$ (f \cdot (g \cdot h)) (s) = \begin{cases} f(2s), & 0 \leq s \leq \frac{1}{2}\\ g(4s-2), & \frac{1}{2} \leq s \leq \frac{3}{4} \\ h(4s-3), & \frac{3}{4} \leq s \leq 1. \end{cases} $$
$$ \phi(s) = \begin{cases} \frac{1}{2}s & 0 \leq s \leq \frac{1}{2}\\ s-\frac{1}{4}, & \frac{1}{2} \leq s \leq \frac{3}{4} \\ 2s-1, & \frac{3}{4} \leq s \leq 1. \end{cases} $$
But clearly, $((f \cdot g) \cdot h) \phi$ and $(f \cdot (g \cdot h))$ are not the same function, for instance, on the interval $[\frac{1}{4}, \frac{1}{2}]$, the former equals to $g(2s-1)$, while the latter is $f(2s)$.
Where is the error?

When I plug in $s=3/8$, for example, I get $f(3/4)$ for both. You seem to agree for the second composition. For the first: $\phi(3/8) = 3/16$, so $((f \cdot g) \cdot h) \phi(3/8) = ((f \cdot g) \cdot h)(3/16)$, and since $3/16 \leq 1/4$, this equals $f(4 \cdot 3/16) = f(3/4)$. The same works for any $s \in [0, 1/2]$: $\phi$ takes the interval $[0,1/2]$ to the interval $[0, 1/4]$, and so into the part of the path given by $f$.