Here is an explicit construction of the equivalence relation generated by a relation $R$ (found in Leinster's book):
First of all, I don't understand the highlighted part. Where does this zigzag come from? Why is having such a zigzag equivalent to $a\sim a'$?
Second, why is the $\sim$ defined at the end indeed the equivalence relation generated by $R$? What would a rigorous proof of this fact be? I'm not even sure I understand what lies behind this definition. For example the statement $(a_0,a_1)\in S$ says that either $a\sim_R a_1$ or $a_1\sim_R a$ for some $a_1\in A$, and I don't see how this is relevant to the equivalence relation generated by $R$.

The book writes $x\to y$ for $(x,y)\in R$. It also uses $x\gets y$ for $(y,x)\in R$.
Since we're assuming that $\sim$ is an equivalence relation containing $R$, necessarily $x\to y$ and $x\gets y$ imply $x\sim y$, because $\sim$ is by assumption symmetric.
We're also assuming that $\sim$ is transitive. The “zigzag” in the example means
Thus every pair of elements “linked by a zigzag” must belong to $\sim$.
Now consider the set $\tilde{R}$ of pairs $(a,a')$ such that either $a=a'$ or there exist $a_0=a,a_1,\dots,a_{n-1},a_n=a'\in A$ with either $a_{k-1}\to a_k$ or $a_{k-1}\gets a_k$, for $k=1,2,\dots,n$ (with $n\ge1$). Note that “either $a_{k-1}\to a_k$ or $a_{k-1}\gets a_k$” is the same as “$(a_{k-1},a_k)\in S$”, in the book's notation.
Then prove that $\tilde{R}$ is an equivalence relation.
Since clearly $\tilde{R}$ contains $R$, it is the equivalence relation generated by $R$, because it just contains what it must contain, that is, the pairs of elements linked by a zigzag.
Note: here I use $n\ge1$ by clarity; the text uses also $n=0$, which accounts for the pairs $(a,a)$, but it's a bit of a stretch for beginners.