I would leave this as a comment, but I don't have the reputation for it. So I'll expand it out a bit.
I may not understand the formulation that you want, but the general statement is false. Here, the general statement I interpret is: "If we have a diagram, made up of triangles and squares (in some sufficient sense), where all triangles and squares commute, then the entire diagram commutes."
Here is a quick counterexample (I apologize for the primitive commutative diagram, I run my cd's through so much personal code I don't really remember how to make them from scratch):
$$\begin{array}{ccccc}
\{1,2\}&\rightarrow&\{1\}&\rightarrow&\{1\}\\
&\nwarrow&\uparrow&&\downarrow\\
&&\{1\}&\leftarrow&\{1\}
\end{array}$$
Any chosen maps work (although I guess only one map has a choice). The triangle and square both commute, but going around the pentagon from $\{1,2\}$ is not the identity map.
To make a statement like "a diagram made up of smaller commutative diagrams commutes" true, one would normally factor the defining functor (from directed graphs to the category) through a preorder. In particular, what is making at least my stated general statement less than true is that non-trivial cycles are allowed. Usually, when people want results like this, the diagrams have a general "direction" which is what makes it work out. Think a page of long exact sequences (maybe with some nifty little triangles in there for fun), where morphisms all move towards the bottom right.
I apologize if I misunderstood your question. With your given precise formulation for $2$-gons, it seems like I interpreted it correctly. But I could easily be mistaken.
EDIT:
On a walk in the rain, I was thinking about how I would formulate the general statement, without appealing to general abstract nonsense. The following statements are less fact-checked than the above.
Note the desire to avoid appealing to general abstract nonsense of "the functor defining the diagram factors through a preorder" is that this isn't really saying much. A preorder is frequently defined as a thin category in this context, and a diagram is trivially commutative if it factors through a thin category (this is the abstract nonsense definition).
First, another counterexample. To emphasize, this is not a counterexample of your chordal statement, but rather an attempt at a generalization. Let $T$ be a terminal object in the category.
$$
\begin{array}{ccccccc}
&&B&\rightarrow&C\\
&\nearrow&&\swarrow&\downarrow\\
A&\rightarrow&T&\leftarrow&F\\
&\searrow&&\nwarrow&\uparrow\\
&&D&\rightarrow&E
\end{array}
$$
The squares $ABCT$ and $ADET$ commute as $T$ is terminal; similarly the triangles $CFT$ and $EFT$ commute. The only other triangle or square I see is $CFET$, which (at least by the definition I usually see) does not have an additional check for commutativity. However, the hexagon $ABCFED$ only commutes if $ABCF$ is the same as $ADEF$, which there is no reason for this to be the case in general.
This counterexample is, perhaps, notable, as it does not have any non-trivial cycles but the result still fails. My above answer at least implied that cycles were the explicit reason for failure, so this gives another explicit way it can fail. Note that this diagram is (hence) not a (categorical) preorder, despite how it might really "feel like" it is ordered "towards" $T$ in some sense.
This, of course, does not satisfy your chordal condition. My general statement would be this. Suppose we have a diagram in a category such that:
- There are no directed $n$-cycles, for any finite $n$.
- Every triangle and square commute.
- The diagram is "strongly composed" of triangles and squares, in the sense that for every undirected $n$-cycle in the diagram (with $n\geq5$), there exists a directed chordal walk bisecting the $n$-cycle into two (again, undirected) cycles of strictly smaller length. To be precise in what I mean, if $v_1,v_2,\dots,v_n$ is an undirected cycle of length $n$, with $n\geq5$, then there exists $k<\ell$ and a walk (in the diagram) $v_k,w_1,\dots,w_m,v_\ell$ (with $m=0$ allowed) such that: (1) the undirected cycle $v_k,\dots,v_\ell,w_m,\dots,w_1$ has length less than $n$; (2) the undirected cycle $v_\ell,\dots,v_n,v_1,\dots,v_k,w_1,\dots,w_m$ has length less than $n$; (3) the walk $v_k,w_1,\dots,w_m,v_\ell$ is either directed or reverse directed.
Then the entire diagram commutes.
This is a slight strengthening of your statement (except the removal of cycles), which simply requires that $m=0$ (where the chord being directed is trivial). This strengthening allows for the example of four commuting squares pushed into a bigger square, as given in the comments, where we have $m=1$.
The requirement about directed cycles, one might think that you could instead require that all directed cycles compose to the identity. This would eliminate my counterexample above, but does not handle:
$$\begin{array}{ccccc}
&&E&\leftarrow&D\\
&\nearrow&&\swarrow&\uparrow\\
A&\rightarrow&B&\rightarrow&C
\end{array}$$
The issue is the square on the left "commuting" tells us nothing. Thus, there is no reason why the pentagon would commute.
The requirement that the chordal walk be directed is about the second counterexample. The chordal walk for the outer hexagon passes through $T$, and is hence not directed.
I didn't fully check the proof of this, but it should be proven by induction on the length of an undirected $n$-cycle. But this is what it would sort of look like.
- We want to prove that $v_1\to v_2\to\dots\to v_t$ and $v_1\to v_n\to\dots\to v_t$ are equal, where the $v_k$ are "distinct". (Note if the $v_k$ are not distinct, we either get a non-trivial directed cycle which is disallowed, or we have multiple cycles of length less than $n$ which would be handled by the inductive hypothesis.) If $n=3$ or $n=4$, then we are done since triangles and squares commute, which is the base case.
- If $t=n$, then we have a directed $n$-cycle which is disallowed. Thus, we know $1<t<n$.
- We now take a directed chordal walk, from $v_k$ to $v_\ell$, with $k<\ell$. We split into various cases. I write some examples below, to show what it looks like with some diagrams. The full proof wouldn't be that much different.
- Example Case 1: $1<k<t<\ell<n$, and the chordal walk points $k$ to $\ell$. We get a diagram that looks like this:
$$\begin{array}{cccc}
v_n&\rightarrow&v_\ell&\rightarrow&v_t\\
\uparrow&&\uparrow&\nearrow\\
v_1&\rightarrow&v_k
\end{array}$$
where the maps are all the composed maps around the cycle, except the $v_k$ to $v_\ell$ map is the directed chordal walk. The "square" on the left is an undirected cycle of length less than $n$, so it commutes by the inductive hypothesis. The "triangle" on the right is similar. Thus, we've reduced to this simple case which is readily verified.
- Example Case 2: $1<k<t<\ell<n$, but the chordal walk points from $\ell$ to $k$. Then we get a similar diagram:
$$\begin{array}{cccc}
v_n&\rightarrow&v_\ell&\rightarrow&v_t\\
\uparrow&&\downarrow&\nearrow\\
v_1&\rightarrow&v_k
\end{array}$$
Again, the "square" and "triangle" are cycles of smaller length, so we can reduce to this case which is readily verified.
- Example Case 3: $1<k=t<\ell<n$, with the chord pointing from $k$ to $\ell$. This looks like:
$$\begin{array}{cccc}
v_n&\rightarrow&v_\ell&\rightarrow&v_{\ell-1}\\
\uparrow&&\uparrow&\swarrow\\
v_1&\rightarrow&v_t
\end{array}$$
This produces a non-trivial cycle, so is discarded. This is a degenerate case of Example Case 1, drawn with a modified diagram to show what is happening.
- Example Case 4: $1<k<\ell<t<n$, with the chord pointing from $k$ to $\ell$. Now we have two paths from $v_k$ to $v_\ell$. This gives the following:
$$\begin{array}{ccccc}
v_n&\rightarrow&v_t&\leftarrow&v_\ell\\
\uparrow&&&\nearrow&\uparrow\\
v_1&\rightarrow&v_k&\rightarrow&v_{k+1}
\end{array}$$
where the diagonal path is the chordal path. We see that this left "pentagon" is shorter than $n$, so by the inductive hypothesis it must commute. Same goes for the "triangle".
- Example Case 5: $1<k<\ell<t<n$, with the chord pointing from $\ell$ to $k$. This gives a similar diagram:
$$\begin{array}{ccccc}
v_n&\rightarrow&v_t&\leftarrow&v_\ell\\
\uparrow&&&\swarrow&\uparrow\\
v_1&\rightarrow&v_k&\rightarrow&v_{k+1}
\end{array}$$
Now we have a non-trivial directed cycle, so this case is discarded.
- Example Case 6: $1=k<\ell=t<n$, with the chord pointing from $k$ to $\ell$. Then we have:
$$\begin{array}{ccccc}
v_n&\rightarrow&v_t\\
\uparrow&\nearrow&\uparrow\\
v_1&\rightarrow&v_2
\end{array}$$
The two "triangles" have length less than $n$ so commute by induction and we are done. This is really a degenerate case of Example Case 4.
- Example Case 7: $1<t\leq k<\ell\leq n$. By symmetry, this would reduce to $1\leq k<\ell\leq t<n$.
Not a very clean argument, but it seems to work to me.