I want to prove that given two groupoids $G$ and $H$, a "functor candidate" $F:G \to H$ between them needs only to preserve compositions, that is, in the case of groupoids, to be a functor it is sufficient to only preserve compositions.
My attempt was:
Let $1_{g}$ to be an unit of $G$. We can write $1_{g} = 1_{g} \circ 1_{g}$. Applying $F$, we get $F(1_{g}) = F(1_{g}) \circ F(1_{g})$. Now, composing with $F(1_{g})^{-1}$ in both sides, we have $F(1_{g}) = 1_{F(g)}$.
Is that correct?
Yes, your proof is correct.
Here is another way to look at the situation and your proof:
This argumentation relies on the following fact from basic group theory:
This is essentially the claim from your question for the special case of one-object groupoids. However, this special case is proven in practically every text on basic group theory. And the proof we find there is the same as yours:
In any group $G$, the only idempotent element is the neutral element: if $g^2 = g$, then by multiplying with $g^{-1}$ we arrive at $g = 1_G$.
Let $f$ be a multiplicative map from $G$ to $H$. Then $1_G^2 = 1_G$, therefore $f(1_G)^2 = f(1_G^2) = f(1_G)$, and thus $f(1_G) = 1_H$.