I'm having some trouble understanding the proof of the following theorem

A subgroup of a cyclic group is cyclic

I will list each step of the proof in my textbook and indicate the places that I'm confused and hopefully somewhere out there can clear some things up for me.

ProofLet $G$ be a cyclic group generated by "$a$" and let $H$ be a subgroup of $G$. If $H = {\{e\}}$, then $H = \langle e\rangle $ is cyclic. If $H \neq \space {\{e\}}$, then $a^n \in H$ for some $n \in \mathbb{Z}^{+}$. Let $m$ be the smallest integer in $\mathbb{Z}^{+}$ such that $a^m \in H$.

We claim that $c = a^m$ generates $H$; that is,

$$H = \langle a^m\rangle = \langle c\rangle.$$

We must show that every $b \in H$ is a power of $c$. Since $b \in H$ and $H \leq G$, we have $b = a^n$ for some $n$. Find $q$ and $r$ such that

$$ n = mq + r \space \space \space \space for \space \space \space 0 \leq r < m,$$

Alright this is the first part in the proof where I start to get confused. Where does the division algorithm come from and why are we using it? The proof continues as follows:

$$a^n = a^{mq + r} = (a^m)^q \cdot a^r,$$

so

$$ a^r = (a^m)^{-q} \cdot a^n.$$

Now since $a^n \in H$, $a^m \in H$, and $H$ is a group, both $(a^m)^{-q}$ and $a^n$ are in $H$. Thus

$$(a^m)^{-q} \cdot a^n \in H; \space \space \space \text{that is,} \space \space a^r \in H.$$

This is another point at which I’m a little confused. What exactly about $a^n$ and $a^m$ being elements of $H$ allows us to accept that $(a^m)^{-q}$ and $a^{n}$ are in $H$? The proof continues:

Since $m$ was the smallest positive integer such that $a^m \in H$ and $0$ $\leq r$ $< m$, we must have $r = 0$. Thus $n = qm$ and

$$b \space = \space a^n \space = \space (a^m)^q \space = \space c^q,$$

so $b$ is a power of $c.$

This final step is confusing as well, but I think its just because of the previous parts I was confused about. Any help in understanding this proof would be greatly appreciated