Solution 1:

I will use $B(x,r)$ for the open ball centered at $x$ with radius $r$, $\bar B(x,r)$ for the corresponding closed ball and $\overline{B(x,r)}$ for the closure of the open ball in $X$.

First, notice that it is sufficient to prove that every closed ball is connected, because of $$B(x,r) = \bigcup_{s<r}\bar B(x,s).$$ (Remember that a union of a family of connected sets with non-empty intersection is connected.)

Suppose some closed ball $\bar B(x,r)$ is disconnected. Then $\bar B(x,r)=U+V$ for some clopen subsets $U,V$ of $\bar B(x,r)$. But $\bar B(x,r)$ is closed in $X$, so $U$ and $V$ are also closed in $X$. Since $X$ is compact, this implies that $U$ and $V$ are compact. Assume without loss of generality, that $x\in U$. Since $V$ is compact, $\min_{y\in V} d(x,y)=:q$ exists. Note that $0<q\leq r$. Fix a point $y\in V$ such that $d(x,y)=q$.

Observe that $B(x,q)\cap V=\emptyset$. Therefore, $B(x,q)\subseteq U$. But $U$ is closed in $X$, so $\overline{B(x,q)}\subseteq U$. On the other hand, $\bar B(x,q)$ contains $y$, so $\bar B(x,q)\nsubseteq U$. So, $\bar B(x,q)\neq\overline{B(x,q)}$.

We conclude that if $\bar B(x,r)=\overline{B(x,r)}$ holds for all $x\in X, r\in[0,\infty)$, all balls must be connected.

Solution 2:

Assume that $X$ is not connected. Then there exists a set $F\subset X$, such that $F, K=X\smallsetminus F$ are non-empty, open and closed, and as they are closed they are compact.

This means that $$ r=\mathrm{dist}(F,K)>0, $$ and further there exist $x\in F$ and $y\in K$, such that $d(x,y)=r$.

In particular, $$\big(F\cup B(x,r)\big)\cap K=\varnothing,$$ and thus $$ F\subset F\cup B(x,r)\subset X\smallsetminus K=F, $$
which implies that $F= F\cup B(x,r)$ and $$ F=\overline F= \overline{F\cup B(x,r)}=\overline F\cup \overline B(x,r), $$ which is a contradiction since $y\not\in F$, but $y\in \overline B(x,r)$.