Which cardinals $\lambda > 2$ have the following property?


There is a space $(X,\tau)$ such that


* for all cardinals $\kappa$ with $1<\kappa<\lambda$ we have $X\not\cong X^\kappa$, and
* $X\cong X^\lambda$.



Space $X$ such that $X^\lambda\cong X$ for some $\lambda$
As was conjectured by Adam in his answer, every finite $n > 2$ has the property you're looking for. Namely, there exists a topological space homeomorphic to its $n$th power and none of its $k$th powers, $1<k<n$. 


The relevant paper is "Homeomorphisms between finite powers of topological spaces" by Orsatti and Rodino. It can be found [here](http://www.sciencedirect.com/science/article/pii/0166864185900446?np=y#). From the abstract:


"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$ (mod $r$)."


From glancing at the paper, the authors adapt a big theorem of Corner, that every countable reduced torsion-free ring is the endomorphism ring of some torsion-free Abelian group, to prove their result. (This is the same theorem Corner himself uses to prove the result cited in Adam's answer.) What they actually produce is a compact and connected topological Abelian group $X$ such that $X^n$ is topologically isomorphic $X^m$ iff $n \equiv m$ (mod $r$), and then use the fact that for such groups any homeomorphism between the underlying spaces must actually be a topological isomorphism. 


