I know why an object G gives you a group when you take all its automorphisms.
But how does an object G give you a monoid when you take all its endomorphisms? What does it mean to compose two endomorphisms?
I know why an object G gives you a group when you take all its automorphisms.
But how does an object G give you a monoid when you take all its endomorphisms? What does it mean to compose two endomorphisms?
Any category, by definition, contains the information of what composition of morphisms means. Specifically, a category $\mathcal{C}$ consists of
a collection of objects $\mathrm{ob}(\mathcal{C})$
for any objects $X,Y\in\mathrm{ob}(\mathcal{C})$, a set of morphisms $\mathrm{Hom}_\mathcal{C}(X,Y)$
for any objects $X,Y,Z\in\mathrm{ob}(\mathcal{C})$, a function (which by abuse of notation is always named $\circ$) $$\circ:\mathrm{Hom}_\mathcal{C}(X,Y)\times\mathrm{Hom}_\mathcal{C}(Y,Z)\to\mathrm{Hom}_\mathcal{C}(X,Z)$$
(which must also satisfy certain axioms). But regardless, the point is that for any object $X$ of any category $\mathcal{C}$, the composition function $$\circ:\mathrm{Hom}_\mathcal{C}(X,X)\times\mathrm{Hom}_\mathcal{C}(X,X)\to\mathrm{Hom}_\mathcal{C}(X,X)$$ is built into the structure of the category itself. This is the binary operation on $\mathrm{Hom}_\mathcal{C}(X,X)$ that makes it into a monoid.
It is just function composition. Say $\phi,\psi:G\rightarrow G$ are functions, if we were in the category of sets, (or endomorphisms assuming they are both endomorphisms in an arbitrary category) then $\phi\circ \psi:G\rightarrow G$ is a function, defined by $x\mapsto \phi(\psi(x))$, and thus an endomorphism, similarly for $\psi \circ \phi$. We can compose any way that we want but, we can't necessarily take inverses (as in the category of sets we can look at when an inverse to a function exists with domain $G$ i.e. injective and surjective). There is an identity so this is a monoid.
A category comes with a composition law; it's part of how we define categories. Generally, given any morphisms $f: A \to B$ and $g: B \to C$, we can compose them to get a morphism $g \circ f: A \to C$. We had to say what $g \circ f$ means when we defined the category that they live in.
Now if you take two morphisms $f, g: G \to G$, then since they have the same domain and codomain, you can always compose them to get a new morphism $f \circ g : G \to G$. This is a binary operation on the set $\text{End}(G)$. It's an associative operation because that's one of the conditions of what it means for something to be a category. It also has an identity element $id_G \in \text{End}(G)$, which by definition satisfies $id_g \circ f = f \circ id_G = f$ for all $f \in \text{End}(G)$. Thus $\text{End}(G)$ is indeed a monoid under this operation.