First, note any group of order $p^2$ is abelian. If $|Z(G)|=p^2$, this is automatic. If $|Z(G)|=p$, then $G/Z(G)$ has order $p$, hence is cyclic, so $G$ is abelian (a well known fact), hence actually $|Z(G)|=p^2$. So necessarily we must be in the first case. Analyzing these two cases suffices since $p$-groups have nontrivial center.
So any group of order $p^2$ is a finitely generated abelian group, hence is a direct product of cyclic subgroups by the structure theorem. The only possibilities are $\mathbb{Z}/(p^2)$ or $\mathbb{Z}/(p)\times\mathbb{Z}/(p)$, so there are only two groups of order $p^2$, up to isomorphism.
Up to isomorphism, there are only two groups of order $10$: the cyclic group $\mathbb{Z}/10\mathbb{Z}$, and the dihedral group $D_{10}$.
One way to see this is to first notice, as you did, that a group $G$ of order $10$ has an element of order $5$ and another of order $2$; the subgroups they generate, say $G_5$ and $G_2$, have order $5$ and $2$, respectively.
Now, since $G_5$ has index $2$, it is a normal subgroup of $G$. Moreover, $G_5$ and $G_2$ have trivial intersection, and $G_5G_2=G$ (this can be seen by looking at the cardinality of $G_5G_2$). Thus $G$ is the semidirect product of those two subgroups: $G=G_5\rtimes G_2$.
Now, semidirect products of the form $G_5\rtimes G_2$ are determined by an action of $G_2$ on $G_5$, or equivalently, by a homomorphism of groups $G_2\to Aut(G_5)$. Since $G_5 \cong \mathbb{Z}/5\mathbb{Z}$, we have $Aut(G_5)\cong \mathbb{Z}/4\mathbb{Z}$, so there are exactly two group homomorphisms $G_2\to Aut(G_5)$ (since $G_2 \cong \mathbb{Z}/2\mathbb{Z}$).
Thus there are exactly two semidirect products $G_5\rtimes G_2$: the one corresponding to the trivial action of $G_2$ on $G_5$ gives $\mathbb{Z}/10\mathbb{Z}$, and the only non-trivial action of $G_2$ on $G_5$ gives $D_{10}$.
For your second, more general question, this post seems to provide the answer.
Best Answer
Let $p>q$ be primes. There exists a non-abelian group of order $pq$ if and only if $p\equiv 1 \bmod q$. Furthermore any tow non-abelian groups of order $pq$ are isomorphic. For a proof use the Sylow theorems. Also, one can find this result in many books. For $p=7$ and $q=3$ we obtain that there is exactly one non-abelian group of order $21$. The abelian groups are $C_{21}\simeq C_3\times C_7$.