Let $A\subseteq (X,d)$ be a compact subset of $X$. Show that $\operatorname{diam}(A)$ is finite and that $\exists x,y \in A$ such that $\operatorname{diam}(A)=d(x,y)$
As $A$ is compact, so $A$ is bounded (and closed). So that $\operatorname{diam}(A)$ is finite.
How can I show the other part?
Let $A$ be a compact subset of a metric space $X$. Then $A\times A\subset X\times X$ is also compact. In particular, $d:X\times X\to \mathbb{R}_{\geq 0}$ is a continuous function. The extreme value theorem gives that $d(A\times A)$ is also compact. Do you see what to do from here?