Could someone show an example of two spaces $X$ and $Y$ which are not of the same homotopy type, but nevertheless $\pi_q(X)=\pi_q(Y)$ for every $q$? Is there an example in the CW complex or smooth category?

There are such spaces, for example $X = S^2 \times \mathbb{R}P^3$, $Y = S^3 \times \mathbb{R}P^2.$ (These are both smooth and CWcomplexes.) Whitehead's Theorem says that for CWcomplexes, if a map $f : X \to Y$ induces an isomorphism on all homotopy groups then it is a homotopy equivalence. But, as the example above shows, you need the map. Such a map is called a weak homotopy equivalence. (Whitehead's Theorem is not true for spaces wilder than CWcomplexes. The Warsaw circle has all of its homotopy groups trivial but the unique map to a point is not a homotopy equivalence.) 


All of these examples involve a bit of cleverness, so I thought I'd point out a more straightforward way to construct counterexamples. If $X$ is any space, we can build a space $X' = K(\pi_0 X, 0) \times K(\pi_1 X, 1) \times K(\pi_2 X, 2) \times \dots$ which has the same homotopy groups as $X$, but which is usually not weakly equivalent to $X$. Pretty much any invariant of spaces other than the homotopy groups will distinguish them. For instance, if $X = S^2$, then $H_3(X) = 0$, but $X'$ contains $K(\pi_3 S^2, 3) = K(\mathbb{Z}, 3)$ as a retract, so $H_3(X')$ contains $H_3(K(\mathbb{Z}, 3)) = \mathbb{Z}$ as a retract and cannot be $0$. Of course, this doesn't produce geometrically nice spaces like smooth manifolds. 


$S^3 \times \mathbb{R}P^2$ and $\mathbb{R}P^3 \times S^2$ are both smooth 5manifolds with fundamental group $\mathbb{Z}/2$ and universal cover $S^3 \times S^2$, so their homotopy groups are all the same. On the other hand, only the latter is orientable since $\mathbb{R}P^3$ is orientable but $\mathbb{R}P^2$ isn't, so they have different values on $H^5$ and therefore can't be homotopy equivalent. (I think this example is in Hatcher somewhere.) 


Along the same lines: you can produce examples involving simply connected finite CWcomplexes, by using $S^1$ actions: $\mathbb{C}P^m \times S^{2n+1}$ and $S^{2m+1}\times \mathbb{C}P^n$ have the same homotopy groups, for instance. It's easy to produce examples with arbitrarily high connectivity: take the homotopy fiber $X$ of any nontrivial map $K(A,m)\to K(B,n+1)$, with $n>m$. Then $X$ and $Y=K(A,m) \times K(B,n)$ have the same homotopy groups, but are not homotopy equivalent. Here's a new question: for given $k$, can you find a pair of $k$connected finite CWcomplexes which have the same homotopy groups, but aren't homotopy equivalent? 


It's easy to construct myriads of such examples using finite $T_0$ topological spaces. These are equivalent in a natural way to finite posets (check this wikipedia article). With a poset $P$ we may associate an abstract simplicial complex $K(P)$ whose simplices are the chains of $P$. It turns out that the geometric realization of $K(P)$ and $P$ are weakly homotopy equivalent (there is a continuous map $K(P) \to P$ inducing isomorphisms on homotopy groups). However, these spaces are not homotopy equivalent (unless they are both homotopy equivalent to a discrete space). Moreover, examples of weakly homotopy equivalent finite spaces that are not homotopy equivalent are also easy to give. The following notes by J.P. May are a nice introduction to this topic: http://www.math.uchicago.edu/~may/MISC/FiniteSpaces.pdf , http://www.math.uchicago.edu/~may/MISC/SimpCxes.pdf 

