I am reading through Category Theory in Context by Emily Riehl. On page 33 she defines a connected category as one in which any pair of objects can be connected by a finite zigzag of morphisms (emphasis added).
Why do we need to specify a finite zigzag? Given an infinite family of morphisms from an object $x$ to an object $y,$ couldn't I just compose all of them to get a single morphism from $x$ to $y?$
My only guess is that "zig-zag" allows for morphisms pointing in opposite directions, e.g.
$$x \rightarrow y \leftarrow z$$
would constitute a zigzag of morphisms. In this case $x$ would be connected to $z$ (even if $\text{Hom}(x,z) = \text{Hom}(z,x) = \emptyset$). On the other hand in the case of a countable family $\{y_i\}_{i=1}^\infty$ of objects, the morphisms
$$x \rightarrow y_1 \leftarrow y_2 \rightarrow \cdots \leftarrow z,$$ would not connect $x$ and $z$.
Is my interpretation correct or am I missing something?
Your guess is correct: the term "zig-zag" refers to a sequence of morphisms which could go in either direction. So, a zig-zag from $x$ to $y$ is a sequence of objects $z_0=x,z_1,z_2,\dots,z_n=y$ together with either a morphism $z_i\to z_{i+1}$ or a morphism $z_{i+1}\to z_i$ for each $i$ from $0$ to $n-1$. The point of this definition is that "$x$ is connected to $z$" (i.e., "there exists a zig-zag from $x$ to $z$") should be the equivalence relation generated by "there exists a morphism from $x$ to $z$". If you imagine the category as a graph where the objects are vertices and the morphisms are edges, a zig-zag is a path from $x$ to $z$ (where we don't care about the directions of the arrows).
(This is a standard term in category theory, but its meaning certainly is not obvious, and I would consider it an error in the book that Riehl uses the term without first defining it.)
There is no such thing as an "infinite zig-zag" from $x$ to $y$ and it would not make sense to talk about such a thing. You can define an infinite zig-zag where your objects are indexed by $\mathbb{N}$ (or $\mathbb{Z}$), but in that case there would be no last (or first) object and so it would not make sense to say that the zig-zag is "from $x$ to $y$".