We will use the Compactness Theorem. Details depend on what book you are using, and where you are in the book. They depend also on whether we mean directed or undirected graphs, and also on whether we have loops and/or multiple edges. I will assume undirected, no loops, no multiple edges.
Consider the following infinite set of sentences $\phi_3$, $\phi_4$, $\phi_5$, and so on. We describe the $\phi_k$ informally, but they are easy to formalize.
The sentence $\phi_3$ says there is no cycle of length $3$. The sentence $\phi_4$ says there is no cycle of length $4$. And so on. It is not hard to write down $\phi_k$ that do the job. And it is clear that the cycle-free graphs are precisely the models of graph theory with added axioms the infinite list $\phi_3$, $\phi_4$, $\dots$.
Now suppose that there is a finite set of formulas, so without loss of generality a single formula $\psi$, such that the models of graph theory with $\psi$ added are precisely the cycle-free graphs.
Then the models of graph theory with $\psi$ added are precisely the same as the models of graph theory with the set $\{\phi_3,\phi_4,\phi_5,\dots\}$ added.
Then by Compactness (and Completeness) there is a finite collection of the $\phi_i$ which, together with the remaining axioms of graph theory, implies $\psi$.
So for some $n$, $\{\phi_3, \phi_4,\dots,\phi_n\}$ (plus graph theory) implies $\psi$.
This is impossible, for there are certainly graphs that have a cycle, but have no cycle of length $\le n$. Just take a necklace with $n+1$ beads.
To turn this into a proof using whatever theorems are, so far, in your particular book, may take a bit of translating.
A detail: How do we say there is no cycle of length $3$? Let us think about how to say there is no cycle from $x$ to $x$, of length $3$. We have to say that there do not exist $x_1$, $x_2$ which are distinct from each other and from $x$, such that $x$ is connected to $x_1$ by an edge, and $x_1$ is connected to $x_2$ by an edge, and $x_2$ is connected to $x$ by an edge. (Note again that this is for undirected graph, no loops, no multiple edges.) Now no cycle of length $4$ should be easy to write down.
Added: The post asks whether a certain kind of argument is on the right track. In a certain sense, the compactness argument above has a general flavour of the type that you describe, it may be a way of making your intuition rigorous. However, one could argue that since a formula can only "describe a finite number of groups," the notion of abelianness should not be definable by a formula. But it is definable by a simple formula. So one has to be careful. That said, many Compactness Theorem arguments have an almost mechanical character, and look much like the one detailed above. So after a while, in many cases, one can legitimately give the one-line proof "This follows from the Compactness Theorem."