This is not true.
It fails for essentially the same reason that the category of topological commutative groups fail to be an abelian category. For simplicity let's work over an algebraically closed field k. Consider the additive group over k, whose underlying scheme is the affine line $\mathbb{A}^1 = Spec \; k[x]$. Also consider the scheme X which is a disjoint union of points $Spec \; k$, where the disjoint union is over all points in $\mathbb{A}^1$.
There is a canonical map $X \to \mathbb{A}^1$ and this induces a group structure on X, making it a group scheme as well. The kernel and cokernel of this map are both zero, yet it is clearly not an isomorphism.
Note that X is not and an affine scheme, so this does not contradict Milne's answer.

