It’s sufficient to look at balls centred at $0$. It’s easiest to see if you represent the $p$-adic rationals in the form $$x = \sum_{k\ge k_0}\frac{x_k}{p^k},$$ where the $x_k$ are the $p$-adic digits of $x$, so that $$B(0,r) = \left\{\sum_{k\ge r} \frac{x_k}{p^k}:\forall k\bigg(x_k\in\{0,1,\dots,p-1\}\bigg)\right\}.$$
Now let $D = \{0,1,\dots,p-1\}$, and give $D$ the discrete topology; I claim that $B(0,r)$, as a subspace of $\mathbb{Q}_p$, is homeomorphic to the product space $D^\omega$, which is of course compact. (In fact it’s a Cantor set.) The homeomorphism is the obvious one: $$h:D^\omega\to B(0,r):\langle x_k:k\in\omega\rangle\mapsto \sum_{k\ge r}\frac{x_{k-r}}{p^k}.$$
Clearly $h$ is a bijection: $$h^{-1}:B(0,r)\to D^\omega:x=\sum_{k\ge r}\frac{x_k}{p^k}\mapsto \langle x_{k+r}:k\in\omega\rangle\;.$$
$B(0,r)$ has a base of clopen sets of the form $B(x,s)$, where $x\in B(0,r)$ and $s\ge r$. Fix such a $B(x,s)$, with $x=\sum_{k\ge r}\frac{x_k}{p^k}$. If $y=\sum_{k\ge r}\frac{y_k}{p^k}\in B(0,r)$, then $|x-y|_p = p^{-m}$, where $m=\min\{k\ge r:x_k\ne y_k\}$, so $y \in B(x,s)$ iff $m\ge s$. In other words, $$B(x,s) = \bigg\{y\in B(0,r):\min\{k\ge r:y_k\ne x_k\}\ge s\bigg\},$$ and therefore $$h^{-1}[B(x,s)] = \bigg\{\langle y_{k+r}:k\in\omega\rangle:(\forall k which is a basic open set in the product $D^\omega$. Thus, $h$ is a continuous bijection. The sets of the form $h^{-1}[B(x,s)]$ are a base for $D^\omega$, so the same calculation shows that $h^{-1}$ is continuous and hence that $h$ is a homeomorphism.