A subgroup of a cyclic group is cyclic - Understanding Proof
For the first question, the appearance of the division algorithm is best explained by its usefulness in the rest of the proof. You might think of it because you want $n=qm$, as you need to show that $a^n$ is a power of $a^m$, but the best you can do at that point is say $n=qm+r$ and then attempt to prove $r=0$.
For the second question, as $a^m\in H$, we have $(a^m)^{-1}\in H$, as subgroups are closed under taking inverses, and then $(a^m)^{-q}=((a^m)^{-1})^q\in H$, as subgroups are closed under multiplication.
First, the use of the division algorithm is for the sake of utility, as it provides a basis for the structure of the proof. Here, we want to relate $n$ with $m$, that is, we want to show that $n$ must be a multiple of $m$, but we start with the fact that what we know of any $n$, then given any positive integer $m$, by the division algorithm, there exist unique integers integers $q$ and $r$, where $0\leq r\lt m$ such that $n = mq + r$.
Essentially that means for any $n$, if we divide by a positive integer $m$, we have a unique integer quotient $q$ and a unique integer remainder $r$ where $0\leq r \lt m$. So to show that $m$ is a multiple of $n$ (no remainder), we want to show that $n = qm + 0$. I.e. we want $n=qm$, in order to show that $a^n$ is a power of $a^m$, but at most we can start with the fact that $n=qm+r$. The objective then is to prove that $r=0$.
For the second question, since $a^m\in H$, it follows $(a^m)^{-1}\in H$, since subgroups are closed under taking inverses. Then, since $a^m, (a^m)^{-1} \in H$, $(a^m)^{-q}=((a^m)^{-1})^q\in H$, since subgroups are closed under multiplication.
Does this clarify matters any?
In the first answer given, at the last part, $a^r$ is a member of $H$, and $0<=r<m$. Since $a^r$ is a member of $H$ and $a^m$ is a member of $H$ where $m$ is the smallest integer s.t. $a^m$ belongs to $H$.
Thus $r>m$. However $r<m$, by Euclid's division lemma. Hence, due to this contradiction, $r=0$, and $n=qm$.