Garrett Ervin's answer to When is $A$ isomorphic to $A^3$? mentions also some results on topological spaces. (Although the question is about topological groups.)
The results mentioned there seem to answer your question - although I do hope that somebody can provide a more elementary solution. (The result from these papers have several additional requirements on the space $X$.)
In particular, the linked answer mentions the paper A. Orsatti and N. Rodino, Homeomorphisms between finite powers of topological spaces, Topology Appl. 23 (1986), no. 3, 271--277.
Let $\lambda$ be an infinite cardinal number. It is proved that, for each positive integer $r$, there exists a compact connected homogeneous topological space $X$ of weight $\lambda$ such that $X^n$ is homeomorphic to $X^m$ iff $n\equiv m \pmod r$. The cardinality of the set of homeomorphism classes of compact connected homogeneous spaces with this property is exactly $2^\lambda$. Moreover every completely regular space of weight $\lambda$ is embeddable in a space of this type.
Another paper with related results of this type is Vìra Trnková: Products of metric, uniform and topological spaces. Commentationes Mathematicae Universitatis Carolinae, vol. 31 (1990), issue 1, pp. 167-180
For every triple of natural number $a$, $b$, $c$ there exists a metric space $X$, the $m$-th power and the $n$-th power of which are
- homeomorphic iff $m\equiv n \pmod a$
- uniformly homeomorphic iff $m\equiv n \pmod {ab}$
- isomoteric iff $m\equiv n \pmod {abc}$