What does it mean when an object appears in a category's diagram multiple times? In my Introduction to Category Theory class, we were being introduced to diagrams and were told that "Each object and morphism may appear more than once in the diagram". At first, I thought that that would just be a visual aid, perhaps to simplify the picture, but it instead seems to have some actual meaning, and I'm confused as to what that meaning is. For example, take the diagram below, which we were shown in class:

We were told that this diagram commutes iff $g \circ f = \text{id}_X$. However, I thought that it would also be a necessary condition for $f \circ g = \text{id}_Y$, as those are two different paths between $Y$ and itself. I asked the professor this question, and he told me that I couldn't take $f \circ g$, as the input of $f$ was a different $X$ as the output of $g$ (this might not have been his exact response, I don't quite remember what he said verbatim). This really confused me, as I don't see how the same object in the same category can have two different properties simultaneously. Could anyone help resolve my confusion?
 A: The explanation you say your professor gave you doesn't make much sense to me, so I'm guessing there was a miscommunication somewhere.
The direction of arrow labeled "$\mathrm{id}_X$" is important here. In any commuting diagram, we are only allowed to move along with the indicated direction, even if some of those arrows may be invertible. It is true that the identity morphism could go in the other direction, but reversing the direction gives us a different diagram, one which may not actually commute. (In fact, commuting diagrams in which there are directed cycles are usually considered to be ill-defined.)
The way the arrows are drawn, we have $g \circ f = \mathrm{id}_X$, and not necessarily $f \circ g =\mathrm{id}_Y$.
A: 
as those are two different paths between  and itself

I don't see 2 different paths between $Y$ and itself.  Are you perhaps thinking you go from $Y$ to $X$ using the right-hand arrow, and then (since the upper left is also an $X$) going from $X$ to $Y$ using the upper arrow?
You can't do that. A diagram should be thought of as a labeled directed graph, where each vertex is labeled with an object, and each directed edge is labeled with a morphism between the corresponding objects. The diagram commutes if and only if for any 2 vertices, and any 2 paths between those vertices, the composition of morphisms of those 2 paths are equal. A path is a sequence of vertices (not labels!) connected by directed edges, exactly as in graph theory. You can't jump between two vertices labeled with the same object. We do not consider two vertices (or edges) having the same label as being the same vertex (or edge).
To clarify another possible point of confusion: The composition $f \circ g$ is defined as a morphism $Y \to Y$, but it does not correspond to sequence of edges in your diagram (there is no path in the diagram consisting of an arrow labeled $g$ followed by an arrow labeled $f$), so it is irrelevant to whether the diagram commutes.
A: The problem is that your professor did not gave you a precise definition of a diagram.
One definition is that a commutative diagram in a category $\mathcal C$ is a functor $A \to \mathcal C$ where $A$ is a small category. The category $A$ is the shape of the diagram.
Your misunderstanding comes from the fact that your professor and yourself have different shapes in mind when looking at the diagram you drew.
For your professor, the shape of the diagram is the category with objects $0,1,2$ and morphisms $a: 0\to 1$, $b: 1\to 2$ and $c: 0\to 2$ (plus of course the identity morphisms). By force in that category, we have $b\circ a=c$. The diagram is then the functor mapping both $0$ and $2$ to $X$, $1$ to $Y$, $a$ to $f$, $b$ to $g$ and $c$ to $\mathrm{id}_X$.
For you, it seems that the shape is the category with the same objects and morphisms, except you add a morphism $d:2\to 0$. The diagram, as you see it, is defined as above except $d$ is mapped to $\mathrm{id}_X$ also. In that settings, the composite $a\circ d \circ b$ is sent to $f\circ g$, and $a\circ d \circ b$ is forcibly $\mathrm{id}_1$ in the shape category, so indeed the diagram yields $f\circ g = \mathrm{id}_Y$.

Basically, it all boils down to the fact that drawing a diagram without explicitly mentioning the shape is ambiguous.
