The easy way to get started is to let $f(x)=2x^2\cos\frac1x$ and observe that this is a continuous function on $\Bbb R\setminus\{0\}$. $S=f^{-1}\big[\{1\}\big]$, the inverse of a closed set under a continuous function, so $S$ is closed. Similarly, $W=f^{-1}\big[(\leftarrow,1]\big]$, so it’s also the inverse image of a closed set and hence closed. It’s clear that $\lim_{x\to\pm\infty}f(x)=\infty\;,$ so $S$ and $W$ must be bounded and hence compact. Thus, it only remains to determine whether they are connected. This requires some closer examination of the function $f$ and the sets $S$ and $W$. I’ll do more than is actually necessary $-$ enough, in fact, to answer the question even without using the shortcut above to see that $S$ and $W$ are compact.
If we can figure out what $S$ looks like, it probably won’t be too hard to see what $W$ looks like, so let’s begin with $S$. The condition that $2x^2\cos\frac1x=1$ can be rewritten as $2x^2=\sec\frac1x\;.$ Now either make a rough sketch or use graphing software to graph $y=2x^2$ and $y=\sec\frac1x$ and see where the graphs cross. You’ll see that they appear to cross in just two places, one on each side of the $y$-axis. Let’s see if we can verify this.
First, both functions are even, so we can limit our attention to $x\ge0$: if they intersect at some positive $x$, they will also intersect at $-x$, and vice versa. Now $\left|\cos\frac1x\right|\le1$ for all $x$, so $\left|\sec\frac1x\right|\ge1$ for all $x$. Clearly $2x^2\ge0$ for all $x$, so we can only get an intersection at values of $x$ for which $\sec\frac1x\ge1$.
$2x^2\ge1$ iff $x^2\ge\frac12$ iff $|x|\ge\frac1{\sqrt2}$, so any intersection with $x\ge0$ must occur at values of $x\ge\frac1{\sqrt2}$. On the other hand, if $x\ge\frac1{\sqrt2}$, then $\frac1x\le\sqrt2<\frac{\pi}2$. Thus, as $x$ increases from $\frac1{\sqrt2}$ towards $\infty$, $2x^2$ increases monotonically from $1$ towards $\infty$, while $\frac1x$ decreases monotonically from $\sqrt2$ towards $0$, and therefore $\sec\frac1x$ decreases monotonically from $\sec\sqrt2$ towards $\sec0=1$ (where $\sec\sqrt2\approx 6.41257$). Clearly these graphs must cross exactly once for $x\ge0$, say at $x=a$, and once again at the symmetrically opposite point $x=-a$ to the left of the $y$-axis. Thus, $S$ is a $2$-point set, $\{-a,a\}$, and as such is compact, complete, and not connected.
Now $W = \left\{x\in \mathbb{R}:2x^2\cos\frac{1}{x} \leq 1\right\}\cup\{0\}\;.$
Certainly $2x^2\cos\frac1x\le1$ whenever $\cos\frac1x\le0$. When $\cos\frac1x>0$ you can divide by the cosine to get $2x^2\le\sec\frac1x\;.$ In the first part we saw that $2x^2\le1$ for $|x|\le\frac1{\sqrt2}$; thus, if $0<\frac1{\sqrt2}$, either $\sec\frac1x<0$, or $2x^2\le1\le\sec\frac1x$, and in either case $x\in W$. Moroever, we saw that for $\frac1{\sqrt2}\le x\le a$, $2x^2\le\sec\frac1x$, so again $x\in W$. On the other hand, we saw that $2x^2>\sec\frac1x$ when $x>a$, so $W\cap(a,\to)=\varnothing$. Finally, $0\in W$ by definition, on $W$ is symmetric about the origin, so $W=[-a,a]$ and is compact, complete, and connected.