Are objects allowed to repeat in commutative diagrams? This seems to be necessary when representing endomorphisms such as the morphism $f : X \to X$ in the category $\mathbf{Set}$, such as when $f$ is a constant function? Or in the category of binary relations, the morphism $R = \{(x, x)\} \subseteq X \times X$?
That is, can commutative diagrams include parts that look like $X \xrightarrow{f} X$ or $X \xrightarrow{R} X$?
The formal definition of a diagram as a functor from an index category $J$ to a category $C$ seems to allow this if different objects in $J$ are mapped to $X$, but I'd like to confirm if my reasoning is correct.
Yes, of course! A functor $J \to C$ need not be injective on objects.
Another example is when you want to take the product of an object with itself.