I am trying to find sufficient and necessary conditions for a relation to be representable as a union of Cartesian squares: $\bigcup_{i\in I}(X_i\times X_i)$ for some family $X_i$ of sets.
One necessary condition is that the relation is symmetric.
What's about other conditions?
The relation will necessarily be reflexive and symmetric (except it doesn't need to be reflexive on elements that are not related to anything).
On the other hand, if $R\subseteq A\times A$ is a reflexive symmetric relation, you can take $I=R$ and $X_i=\{a,b\}$ for all $i=(a,b)\in R$.