Showing that a totally bounded set is relatively compact (closure is compact)

First of all, you're missing the assumption that $(X,d)$ is a complete metric space. If we don't assume that, the statement is false, as for $X = \mathbb{Q}$ (usual metric) we have that $(0,1) \cap \mathbb{Q}$ is totally bounded and its closure $[0,1] \cap \mathbb{Q}$ is not compact.

Fact: if $E$ is totally bounded then so is $\overline{E}$.

(Proof: suppose that $r>0$ has been given. Then $E$ is covered by finitely many open balls $B(x_i,\frac{r}{2}), i=1,\ldots n$. Then certainly $E \subseteq \cup_{i=1}^n D(x_i, \frac{r}{2})$, where $D(x,s) = \{y \in X: d(y,x) \le s\}$ is a closed ball. The finite union of closed balls is closed, so $\overline{E} \subseteq \cup_{i=1}^n D(x_i, \frac{r}{2}) \subseteq \cup_{i=1}^n B(x_i,r)$. As $r>0$ was arbitary, $\overline{E}$ is totally bounded.)

So we know that $\overline{E}$ is totally bounded and complete (as a closed subset of the complete $(X,d)$). So $\overline{E}$ is compact (every sequence has a Cauchy subsequence, which converges, and so we have sequential compactness).

Relatively compact always implies totally bounded (a sequence in $E$ has a convergent subsequence with limit in $\overline{E}$ by relative compactness, and a convergent subsequence is a Cauchy subsequence, so $E$ is totally bounded), but for the reverse implication we really need completeness of $(X,d)$, as I showed above.