How do we know that composition of morphisms are defined? This is the following definition of a category I am working with, which has been paraphrased from Introduction to Topological Manifolds by John Lee

A category $C$ consists of the following
  
  
*
  
*a class $\text{Obj}(C)$, whose elements are called objects of $C$
  
*a class $\text{Hom}(C)$ whose elements are called morphisms of $C$    
  
  
  with the following properties
  
  
*
  
*for each morphism $f \in \text{Hom}(C)$ there exists two objects $X, Y \in \text{Obj}(C)$ called the source and target of $f$ respectively
  
*for each triple $X, Y, Z$ of objects in $C$, there exists a mapping $\varphi$ called composition: $$\varphi: \text{Hom}_C(X, Y) \times \text{Hom}_C(Y, Z) \to \text{Hom}_C(X, Z)$$ defined by $\varphi(f, g) = g \circ f$, where $\text{Hom}_C(X, Y)$ denotes the class of all morphisms with source $X$ and target $Y$. 
  

Now the last property is what confuses me a bit. The most glaring issue, is that how to do we know that composition of morphisms is even defined for every $f \in \text{Hom}_C(X, Y)$ and $g \in \text{Hom}_C(Y, Z)$? Is it something that we have to prove, when proving that something is a category?
The second thing that confuses me is why do we even need to define this mapping  between $\text{Hom}_C(X, Y) \times \text{Hom}_C(Y, Z)$ and $\text{Hom}_C(X, Z)$? It seems like a lot of trouble to go through especially considering we're working with classes instead of sets. 
Why couldn't we instead say for each $f \in \text{Hom}_C(X, Y)$ and each $g \in \text{Hom}_C(Y, Z)$ there exists a $h \in \text{Hom}_C(X, Z)$ such that $h = g \circ f$? (*)
My guess is that proving the existence of this mapping $\varphi$ called composition for a given category $C$ implicitly requires the condition of the last paragraph and the condition that composition of morphisms is well defined.
But even so, if we use what I say in paragraph (*) instead of having to consider $\varphi$ we would also have to check that composition of morphisms is defined and it would be simpler I would think than having to work with $\varphi$.
 A: You have mangled the definition in several ways.  Most importantly, the following is wrong:

A category $C$ consists of the following
  
  
*
  
*a class $\text{Obj}(C)$, whose elements are called objects of $C$
  
*a class $\text{Hom}(C)$ whose elements are called morphisms of $C$    
  
  
  with the following properties

A category does not merely consist of these two classes.  It also consists of the source, target, and composition operations mentioned afterwards.  For instance, the source operation is a (class) function $\operatorname{Hom}(C)\to\operatorname{Obj}(C)$, taking each morphism to its source object.  The composition operation is really a class function which for each triple $(X,Y,Z)\in\operatorname{Obj}(C)$ outputs a function $\varphi_{(X,Y,Z)}:\text{Hom}_C(X, Y) \times \text{Hom}_C(Y, Z) \to \text{Hom}_C(X, Z)$.
So, the existence of composition is not really something you "prove"--it's part of the very data of a category in the first place, so you haven't even defined a "candidate" category (which you would then check satisfies the required axioms) until you have written down the composition operation.  This is just like how in order to define a group you don't just define a set; you also have to define the group operation.  Only once you have the set and the group operation can you verify whether it satisfies the group axioms.
To be clear, the operation of "composition" in a category does not have to have any relation to the usual composition of functions.  The equation $\varphi(f,g)=g\circ f$ is the definition of the symbol $\circ$, not of $\varphi$.  The function $\varphi$ is specified as part of the data of the category, and then $g\circ f$ is a notation we commonly use instead of $\varphi(f,g)$.  So $\circ$ does not denote function composition or any other pre-defined operation which you are assuming your category is "closed" under; it is just a notation to write down the operation which is part of the category itself.
A: 
Now the last property is what confuses me a bit. The most glaring issue, is that how to do we know that composition of morphisms is even defined for every $f \in \text{Hom}_C(X, Y)$ and $g \in \text{Hom}_C(Y, Z)$? Is it something that we have to prove, when proving that something is a category?

Yes, if we are to prove two classes $O = \operatorname{Obj}C, H = \operatorname{Hom}C$ consist a category, we should specify source and target maps $\mathrm{dom,cod}\colon H\to O$ and all $\varphi$s (and finally, show that $\varphi$s is associative, and that there are identity morphisms).
Then, $\varphi$s define morphism composition. I’m not sure for what reason the quote given states it that unclearly:

<…> defined by $\varphi(f, g) = g \circ f$

as there are clearly no $\circ$ mentioned beforehand. For the same reason (*) is not defined either.
There are other formulations: for example one could combine all $\varphi$s in one partial operation and state some equivalent of “composition-definedness” for it, but after that all the workings are the same.
