Suppose that I'm interested in finding all group homomorphisms from $\mathbb{Z}_7$ to $\mathbb{Z}_{12}$. The textbook has provided a brief explanation:
Let $\phi$ be such a homomorphism. Since the kernel of ϕ must be a subgroup of $\mathbb{Z}_7$, there are only two possible kernels, $\{0\}$ and all of $\mathbb{Z}_7$. The image of a subgroup of $\mathbb{Z}_7$ must be a subgroup of $\mathbb{Z}_{12}$. Hence, there is no injective homomorphism; otherwise, $\mathbb{Z}_{12}$ would have a subgroup of order $7$, which is impossible. Consequently, the only possible homomorphism from $\mathbb{Z}_{7}$ to $\mathbb{Z}_{12}$ is the one mapping all elements to zero.
The explanation makes sense except for the conclusion. Why does non-injectivity imply the above conclusion?
There are only two possibilites for the homomorphism: trivial or injective (this corresponds to the only two possibilities for the kernel: kernel $\Bbb Z_7$ gives trivial homomorphism and kernel $\{0\}$ gives injective homomorphism). They have concluded that injective isn't possible, so trivial is the only option left.
A common alternative approach works on an element-by-element level: We know $0_7$ must be mapped to $0_{12}$. What about any of the other elements? Well, for any $n\in \Bbb Z_7$, we have $7\cdot n = 0_7$, so whatever we map $n$ to in $\Bbb Z_{12}$, that property must be upheld. Which $k\in \Bbb Z_{12}$ are such that $7\cdot k = 0_{12}$? Those are the only possible images of elements in $\Bbb Z_7$.