In what metric spaces is a closed and bounded set compact? Is there a characterization of a metric space $X$ such that for every $A\subseteq X$, $A$ is compact iff $A$ is closed and bounded? Something that generalizes $\mathbb R^n$?
 A: Such spaces are called proper in the literature I'm familiar with (there may be other names in use too). The property stated in your post is   usually taken as definition. An equivalent way to state the definition is "every closed ball is compact". 
Since the property is so simple, it's hard to give a characterization that's not tautological. Here is one:

$X$ is proper iff it is complete and every ball can be covered by finitely many ball half its size. 

More formally stated, the latter property says that $B(x,r) $ can be covered by $\bigcup_{i=1}^N B(x_i,r/2)$. Here $N$ is allowed to depend on $x$ and $r$. It does not matter whether we use open or closed balls here. 
The proof is easy. Being able to cover $B(x,r)$ by balls of radius $r/2$, we can iterate the process and cover by finitely balls of radius $B(x,\epsilon)$ for any $\epsilon>0$ we wish. Thus, every ball is totally bounded. Since the space is complete, it follows that every closed ball is compact. 
The converse is even easier: apply compactness to the cover of closed ball $B$ by open balls half the size, centered at every point of $B$.

As an aside, doubling metric spaces are defined by a similar, but stronger condition: for them, $N$ must be independent of $x,r$. A complete doubling space is proper.
