Here is s a different reason why the property is rare: Consider a topological space $X$ with a continuous surjection $f \colon X \rightarrow X$ that is not a homeomorphism. Assume $f = g_n \circ \ldots \circ g_1$, where each $g_i$ is a homeomorphism or a continuous retraction. Since $f$ is surjective, $g_n$ must be surjective and is hence not a nontrivial retraction. It follows that it must be a homeomorphism. We obtain $g_n^{-1} \circ f = g_{n-1} \circ \ldots \circ g_1$, and we can repeat the arguments to conclude each $g_i$ is a homeomorphism. Thus $g_n \circ \ldots \circ g_1$ is a homeomorphism, whereas $f$ is not. Contradiction. Thus, the statement fails whenever the space has a continuous surjective selfmap that is not a homeomorphism. Thus, it even fails for discrete spaces of infinite cardinality.