Remember that saying that
$ A\stackrel{f}{\to} B\stackrel{g}{\to} C$
"is exact at $B$" means that $\mathrm{im}(f)=\ker(g)$. To say that a sequence
$$\cdots \stackrel{f_{i-1}}{\longrightarrow} A_{i-1}\stackrel{f_i}{\longrightarrow}A_i\stackrel{f_{i+1}}{\longrightarrow}A_{i+1}\stackrel{f_{i+2}}{\longrightarrow}\cdots$$
"is exact" means that it is exact at each $A_i$. To say that you have a "short exact sequence"
$$0\to A\stackrel{f}{\longrightarrow} B \stackrel{g}{\longrightarrow} C\to 0$$
means that this is exact at $A$, $B$, and $C$. In particular:
- $\mathrm{Im}(f)=\ker(g)$;
- The kernel of $f$ is the image of the map $0\to A$... which is $\{0\}$. So $f$ is one-to-one.
- The image of $g$ is the kernel of the map $C\to 0$... which is all of $C$, so $g$ is surjective.
That means that if you say that you have a short exact sequence
$$0 \to A \to B \to C \to 0,$$
means that $B$ has a subgroup $A'$ isomorphic to $A$, and that the quotient $B/A'$ is isomorphic to $C$.
From
$$0 \to \mathbb{Z}/2\mathbb{Z}\to B\to\mathbb{Z}/2\mathbb{Z}\to 0$$
we know that $B$ has a subgroup $A$ that is isomorphic to $\mathbb{Z}/2\mathbb{Z}$, and that $B/A$ is isomorphic to $\mathbb{Z}/2\mathbb{Z}$. This tells you that $|A|=2$, and that $|B/A|=2$, and therefore that $|B|=4$. In particular, it certainly cannot be the case that $B=\mathbb{Z}/2\mathbb{Z}$.
Given the tags in the post, I am working in the context of abelian groups only, so... which abelian groups of order $4$ have a subgroup of order $2$ with quotient of order $2$? Well... all of them. So $B$ can be either $\mathbb{Z}_4$, or $\mathbb{Z}/2\mathbb{Z}\oplus\mathbb{Z}/2\mathbb{Z}$.
If you have
$$0 \to \mathbb{Z}/3\mathbb{Z} \to B \to \mathbb{Z}/5\mathbb{Z}\to 0$$
then you have an abelian group $B$ with a subgroup $A$ of order $3$, and such that $B/A$ is cyclic of order $5$. Hence $5 = |B/A| = |B|/|A| = |B|/3$, so $|B|=15$. There is one and only one abelian group of order $15$ (in fact, there is one and only one group of order $15$), so $B$ is that group: $\mathbb{Z}/15\mathbb{Z}$. The same thing happens with
$$0 \to \mathbb{Z}/3\mathbb{Z}\to B\to\mathbb{Z}/7\mathbb{Z}\to 0$$
which you ask in the comments: $B$ must be the cyclic group of order $21$. More generally if $A$ and $C$ are abelian groups of relatively prime order, then the exact sequence
$$0\to A\to B\to C\to 0$$
forces $B$ to be isomorphic to $A\oplus C$. In the two latter examples above, $\mathbb{Z}/3\mathbb{Z}\oplus\mathbb{Z}/5\mathbb{Z}$ (which is isomorphic to $\mathbb{Z}/15\mathbb{Z}$) and $\mathbb{Z}/3\mathbb{Z} \oplus \mathbb{Z}/7\mathbb{Z}$ (which is isomorphic to $\mathbb{Z}/21\mathbb{Z}$).