Yes, in the given situation, one could just use $r = \operatorname{dist}(A,B)$, and then have
$$N_r(A) = \bigcup_{x\in A} B_r(x) = \{ y\in X : \operatorname{dist}(y,A) < r\}$$
as a convex open neighbourhood of $A$ disjoint from $B$.
But of course, to use that result, $\operatorname{dist}(A,B) > 0$ must have been proved. In the setting of a normed space, that is a one-liner by stating that the continuous function $y \mapsto \operatorname{dist}(y,B)$ attains its minimum on the compact set $A$, and $\{x\in X : \operatorname{dist}(x,B) = 0\} = \overline{B} = B$.
I suspect that the several-lines proof in your notes proves the more general proposition that in a locally convex space, there is a convex open neighbourhood $U$ of $0$ with $(A + U) \cap B = \varnothing$ when $A$ and $B$ are disjoint convex sets with $A$ compact and $B$ closed. The proof in the more general setting is a bit more complicated than for normed spaces (or for locally convex spaces with a translation-invariant metric whose balls are convex, where the same argument as for normed spaces works).