It's weird, but none of introductory category theory books I've seen so far provide rigor definition of "diagram commutes" saying, however they do use such a term extensively.
As far as I was able to deduce from a context, one says that diagram commutes iff there always exists exactly one arrow satifsying somewhat composition. Let's take natural transformation as a simple example: $$G(f) \circ \alpha_A = m = \alpha_{A'} \circ F(f)$$ By saying that such a "square commutes" it is meant that there is unique morphism $m$ equal to the specified compositions.
Is it correct?
You're basically right. A diagram commutes iff every composition of arrows from a given object $X$ to a given object $Y$, via any number of intermediate steps, is the same morphism.