The answer to this quite beautiful question is that there *does exist* a commutative ring $R$ with $R\cong R[X,Y]$ but $R\not\cong R[X]$.

Let $F$ be a field, and take
$$
R=F[x_i,y_i,r_i\ (i\geq 0)]
$$
subject to the relations
$$
\forall\ i\geq 0,\ r_i=x_i y_i(x_i+y_i^2)(x_i+y_i^3)(x_i+y_{i+1}^4)r_{i+1}.
$$

**First**, note that the relations allow us to remove $r_0$ (or more generally, any finite number of the $r_i$) from the list of generators for $R$, and hence
$$
R=(F[x_i,y_i,r_i\ (i\geq 1)])[x_0,y_0]\cong R[X,Y]
$$
where the isomorphism comes from the fact that the relations are unchanged after shifting all of the indices.

**Second**, by direct inspection we see that if $s$ and $t$ are irreducible factors of $r_0$ such that $s+t^2$ and $s+t^3$ are also irreducible factors of $r_0$, then $s=x_i$ and $t=y_i$ for some $i\geq 0$. (Note that if we changed the relations by dropping the factor $x_i+y_i^3$, we would only have this fact up to associates. By having the two irreducibles $x_i+y_i^2$ and $x_i+y_i^3$ simultaneously, we don't need to worry about unit multiples. There might be a more clever way to deal with this minor issue. One could also work over $\mathbb{F}_2$ to avoid unnecessary units.)

**Third**, the relations are homogeneous in the $r$-letters. I claim that this will show that an element of $R$ has infinitely many non-associate irreducible factors if and only if it belongs to the ideal $I=(r_0,r_1,r_2,\ldots)$. Let $a\in R$ be arbitrary. After using the relations, we may write $a$ as a polynomial in $r_m$ with coefficients in $F[x_0,y_0,\ldots, x_m,y_m]$ (for $m$ sufficiently large). Note that if we use the relations in any way (such as by increasing $m$ further), the $r$-degree doesn't change, and the constant term of the polynomial also remains unchanged. However, it is easy to see that if we factor $a$ into irreducible factors, the number of those factors is bounded above by the $r$-degree of $a$ plus the number of irreducible factors of the constant term (which are both invariants of the relations). This number is infinite if and only if the constant term is zero (i.e., $a\in I$), and of course conversely if $a\in I$ then it has infinitely many non-associate irrreducible factors.

**Fourth**, assume by way of contradiction there is an isomorphism $\varphi:R[z]\to R$. Since the set of elements with infinitely many non-associate irreducible factors is an invariant of isomorphisms, and since the third fact above also holds for $R[z]$, we see that the preimage of $r_0$ under $\varphi$ must belong to the ideal generated by $(r_0,r_1,r_2,\ldots)$ in $R[z]$. Thus, there is some element $b\in R[z]$ and some $k\geq 0$ so that $\varphi(r_k b)=r_0$. Thus $\varphi(x_k),\varphi(y_k),\varphi(x_k)+\varphi(y_k)^2,\varphi(x_k)+\varphi(y_k)^3$ are all irreducible factors of $r_0$, and so by the second fact above we must have $\varphi(x_k)=x_{\ell}$ and $\varphi(y_k)=y_{\ell}$ for some $\ell\geq 0$. The same result also holds for $\varphi(x_{k+1}),\varphi(y_{k+1})$, but since $\varphi(x_k)+\varphi(y_{k+1})^4=x_{\ell}+\varphi(y_{k+1})^{4}$ is also an irreducible factor of $r_0$, we must have $\varphi(x_{k+1})=x_{\ell+1}$ and $\varphi(y_{k+1})=y_{\ell+1}$. Repeating the argument, we have $\varphi(x_{k+i})=x_{\ell+i}$ and $\varphi(y_{k+i})=y_{\ell+i}$ for all $i\geq 0$.

Let $J=(x_k,y_k,x_{k+1},y_{k+1},\ldots)$ be the ideal of $R[z]$ generated by the "tail" end of the $x$ and $y$ letters. Then $\varphi(J)=(x_{\ell},y_{\ell},x_{\ell+1},y_{\ell+1},\ldots)$. Thus, the isomorphism $\varphi$ induces an isomorphism
$$
R[z]/J\cong R/\varphi(J).
$$
The factor ring on the left is isomorphic to $F[z,x_0,y_0,x_1,y_1,\ldots, x_{k-1},y_{k-1}]$ which has odd dimension. The factor ring on the right is isomorphic to $F[x_0,y_0,\ldots, x_{\ell-1},y_{\ell-1}]$ which has even dimension. This gives us the necessary contradiction.

An easy modification of this construction will also show that for each modulus $m\geq 2$, there exists a ring $R_m$ such that $R_m[X_1,X_2,\ldots, X_p]\cong R_m[X_1,X_2,\ldots, X_q]$ if and only if $p\equiv q\pmod{m}$.

Edited to add: Taking the same ring but using non-commuting letters should answer the same question for noncommutative rings.