Let $A$ be an open subset $\mathbb{R}^{n}$ and $K\subset A$ is compact. Prove there exist an $r\gt0$ such that the set $$ D=\{y\in \mathbb{R}^{n}: \|y-x\|\leq r \text{ for some }x \in K\}$$ is a compact subset of $A$.
.
Let $y\in cl(D)$ (closure of D), there exist a sequence $y_n$ in $D$ which converges to $y$. This implies that $\|y_n-x_n\|\leq r$, now $x_n$ is a sequence in $K$ and must have a convergent subsequence(due to compactness of K) and point of convergence in $K$, say $x$.
We choose the subsequence of $y_n$ in such way to match with numbering of subsequence of $x_n$.
$\|y-x\|\leq \|y_{n_k}-y\|+\|y_{n_k}-x_{n_k}\|+\|x_{n_k}-x\|\leq 2\epsilon+r$
This implies $y\in D$ and $cl(D)=D$. $\blacksquare$
I have doubt whether I'm missing something and I haven't made use of the set $A$ at all and also the existence of $r>0$
You've proved that $D$ is a compact set for any $r$, but you haven't shown that an $r$ exists such that $D\subset A.$
For each $x\in K$, find $r_x>0$ such that $\displaystyle{N_{r_x}(x)\subseteq A.}$ We can do this since $x\in A,$ and $A$ is open.
Now, let $\displaystyle{U_x=N_{r_x/3}(x).}$
Then $\bigcup_{x\in K} U_x$ is obviously an open cover of $K$, so we must have an $x_1,x_2,\dots,x_n\in K$ such that:
$$K\subseteq \bigcup_{i=1}^{n} U_{x_i}\subseteq A$$
Now, let $\displaystyle{r=\frac 13\min {r_{x_i}}.}$ This is positive since it is the minimum of a finite set of positive reals.
We will show that this $r$ works.
If $y\in D$ then there is some $y_0\in K$ such that $|y-y_0|\leq r.$
Since the $U_{x_i}$ cover $K,$ there must be an $x_i$ such that $y\in U_{x_i},$ which means $\displaystyle |y_0-x_i|<r_{x_i}/3.$
Now $r<\frac{r_{x_i}}{3}$ so we have that:
$$|y-x_i|\leq |y-y_0|+|y_0-x_i|<\frac{2}{3}r_{x_i}$$
Which means that $$y\in N_{r_{x_i}}(x_i)\subseteq A.$$
You definitely need compactness.
If $A=\{(x,y)\mid |xy|<1\}$ and $K=\{(0,y)\mid y\in\mathbb R\},$ then $A$ is open and $K$ is closed, but you don't have a value $r$.
If $A=(-1,1)\subseteq \mathbb R^1$ and $K=[0,1)$, then $K$ is bounded, and even closed as a subset of $A$, but is not closed in $\mathbb R$, hence not compact, and again there is no $r.$
Another approach, using Cantor's intersection theorem.
Let $D_r$ be the set you get for a value $r>0.$ You've already shown that $D_r$ is compact for all $r.$
Now, assume that there is no $D_r\subseteq A.$ Then let $$C_r=D_r\setminus A=D_r\cap(\mathbb R^n\setminus A)$$
Since $\mathbb R^n\setminus A$ is closed, $C_r$ is a closed subset of $D_r,$ hence compact. We also have $C_{r}\subseteq C_{r'}$ if $r<r'.$ And, by our assumption, the $C_r$ are non-empty.
So we have that $\bigcap_{k=1}^{\infty} C_{1/k}$ is the intersection of a nested chain of non-empty compact sets, and hence is non-empty by Cantor's intersection theorem. So there is a $y$ such that $y\in C_{1/k}$ for all $k.$
Since $C_{1/k}\subseteq D_{1/k},$ this means that for each $k>0$ there is an $x_k\in K$ such that $|y-x_k|\leq\frac{1}{k}.$ But then $x_k\to y,$ and thus $y\in K$, contradicting that $y\not\in A.$
This means some $C_{1/k}$ is empty, which means that $D_{1/k}\subseteq A.$