Smoothly homeomorphic for invariance of domain and invariance of dimension Follow-up to this: Do homeomorphic smooth manifolds, like diffeomorphic ones, have the same dimension?
Based on this question Viewing invariance of domain as a converse of invariance of dimension, why then exactly is the following wrong (I mean, I guess it's true for Euclidean spaces $M$ and $N$ but wrong arbitrary manifolds $M$ and $N$. I'm just not sure which direction/s, and why)?

Let $U$ be an open subset of a smooth $n$-manifold $N$. Let $S$ be a subset of a smooth $m$-manifold $M$. Let $U$ be smoothly homeomorphic to $S$. Then $m=n$ if and only if $S$ is open in $M$.

Update: It's true and true even without smoothly. See answer below.
 A: Actually, I think I have a proof of this. I don't even think the smoothness of the homeomorphism is even required. It seems like this is a purely topological result.
I was thinking about this question from your previous post for a while.
Let me know if there are any mistakes.

Theorem. Let $U$ be an open nonempty subset of a smooth $n$-manifold $N$. Let $S$ be a subset of a smooth $m$-manifold $M$. Suppose there is a homeomorphism $f:U\rightarrow S$. Then $m=n$ if and only if $S$ is open in $M$.

Proof. $(\impliedby).$ Suppose $S$ is open in $M$.
Let $p\in S$ (which exists because $U$ is nonempty and $S = f(U)$), let $(X, \phi)$ be a chart of $M$ containing point $p\in S$, and let $(Y, \psi)$ be a chart of $N$ containing point $f^{-1}(p)\in U$.
We claim $f(Y\cap U)\cap (X\cap S)$ is open in $X$. Clearly $Y\cap U$ is an open subset of $U$, so by the homeomorphic property of $f$, the set $f(Y\cap U)$ is an open subset of $S = f(U)$. Since $S$ is open in $M$, the set $f(Y\cap U)$ is open in $M$. Since $S$ is open, $f(Y\cap U)\cap S$ is open in $M$. Therefore, $f(Y\cap U)\cap (X\cap S)$ is open in $X$.
Applying the map $\phi:X\rightarrow\phi(X)$ shows $\phi(f(Y\cap U)\cap (X\cap S))$ is open in $\phi(X)\subseteq \mathbb{R}^{m}$ and hence in $\mathbb{R}^{m}$ (because $\phi(X)$ is open).
By the similar reasoning as in the above two paragraphs, one can show that the set $\psi((Y\cap U)\cap f^{-1}(X\cap S))$ is open in $\mathbb{R}^{n}$ (go over the same reasoning as above; I think you need to do this before you move on to the next paragraph below and I don't think there are shortcuts to this).
Now the composition of homeomorphisms $\psi\circ f^{-1}\circ \phi^{-1}$ sends $\phi(f(Y\cap U)\cap (X\cap S))$ to $\psi((Y\cap U)\cap f^{-1}(X\cap S))$. As we have shown, the former is open in $\mathbb{R}^{m}$ and the latter is open in $\mathbb{R}^{n}$. Also, they are nonempty because the former contains $\phi(p)$ and the latter contains $\psi(f^{-1}(p))$. By applying the last theorem I wrote in this post, we deduce that $m=n$.
$(\implies).$ Suppose $m=n$. Let $p\in S$. Let $(X, \phi)$ be a chart for $M$ containing $p$, and let $(Y, \psi)$ be a chart for $N$ containing $f^{-1}(p)$.
By the homeomorphism property, $f(Y\cap U)$ is open in $S = f(U)$, and by the subspace topology, $f(Y\cap U)\cap (X\cap S)$ is also open in $S$.
By applying $f^{-1}$, the set
$$(Y\cap U)\cap f^{-1}(X\cap S)$$
is open in $U$.
Since $U$ is open, that set is open in $M$; since $Y$ is open, that set is open in $Y$.
By applying $\psi:Y\rightarrow\psi(Y)$, the set $\psi((Y\cap U)\cap f^{-1}(X\cap S))$ is open in $\psi(Y)$, which means it is open in $\mathbb{R}^{n}$.
Then
$$ \phi\circ f\circ\psi^{-1}:\psi((Y\cap U)\cap f^{-1}(X\cap S))\rightarrow \phi(f(Y\cap U)\cap (X\cap S))\subseteq\mathbb{R}^{n} $$
is a continuous injective map, and we know the domain $\psi((Y\cap U)\cap f^{-1}(X\cap S))$ is open in $\mathbb{R}^{n}$ (we can't say the same about the image of the function, however, because not knowing $S$ is open means we don't know whether $X\cap S$ is open in $X$). By applying Theorem 2 of this link, we find that the set
$$ \phi(f(Y\cap U)\cap (X\cap S)) $$
is open in $\mathbb{R}^{n}$. Then $f(Y\cap U)\cap (X\cap S)$ is open in $X$, and hence in $M$ (because $X$ is itself open).
But now we've shown something interesting: for any $p\in S$, there exists an open subset of $M$ of the form $O_{p} = f(Y\cap U)\cap (X\cap S)$ such that
$$ p\in O_{p}\subseteq S. $$
Therefore, we can write $S$ as a union of open sets: $S = \bigcup_{p\in S} O_{p}$ and therefore $S$ is open in $M$.
$$\tag*{$\blacksquare$}$$
