This is a particular and a "partial" case of the Chinese Remainder Theorem. The problem also appeared in the book "Topics in Algebra " by I.N Herstein in the chapter of Ring Theory. But we can do it in a much elegant way. Here is a basic solution to the problem:
We consider the numbers $a,a+2m,a+3m,\cdots,a+(n-1)m.$
We note that this is a complete residue system congruent modulo $n.$
Definition: A set $S$ of integers is called a complete residue system congruent modulo $n$ (, where $n\in\Bbb Z$) if every $y\in \Bbb Z$ is congruent to one and only one numbers from the set $S.$ For example, $S=\{0,1,2,...,n-1\}$ is a complete residue system congruent modulo $n$ as, ever integer $y$ leaves a remainder $r\in S$ when divided by $n$ i.e $y=nq+r$ so, $y\equiv r(\in \Bbb Z)\pmod n.$ Also, as this $r$ is unique( for a number cannot leave two different remainders!) so, this proves that $S$ is a complete residue system. Also, this set $S$ is not unique. The set, $S'=\{1,2,...,n\}$ may also serve as a complete residue system modulo $n.$ (Why?)
Lemma: A set of $n$ integers is called a complete residue system congruent modulo $n$ iff no two of those $n$ numbers are congruent to each other modulo $n.$ (Prove!)
(For a more detailed discussion on these above facts please refer to Chapter -2 of the book, "An Introduction to the Theory of Numbers" by Niven,Zuckerman and Montgomery.)
Ok, so we come back to the problem. The set $a,a+2m,a+3m,\cdots,a+(n-1)m $ is a complete residue system congruent modulo $n.$ This is because, it satisfies the lemma above.
To prove this, we need to show that no two of these $n$ numbers are congruent modulo $n.$ Let us assume the contrary, for the sake of contradiction.
Say, $p=a+k_1m,q=b+k_2m\in \{a,a+2m,a+3m,\cdots,a+(n-1)m\}$ and $p\neq q$(i.e $k_1\neq k_2$). If $p\equiv q\pmod n$ then it means that $$a+k_1m\equiv a+k_2m\pmod n\implies n|m(k_1-k_2)\implies n|(k_1-k_2),$$ as $\gcd (a,m)=1.$ But $k_1,k_2\in\{0,1,...,n-1\}$ so this pissible only if, $k_1=k_2$, a contradiction.
So, indeed, $a,a+2m,a+3m,\cdots,a+(n-1)m $ is a complete residue system congruent modulo $n.$ So, each of these $n$ numbers leaves a remainder of $\{0,1,2,...,n-1\}$ in some order.
Given, $a,b\in \Bbb Z$ so, $b\equiv a+km(=x)\pmod n,$ where $k\in\{0,1,2,...,n-1\}.$ This means, $x=a+km=b+nk'$ where $k'\in\Bbb Z.$
Now, we observe, that, $x=a+km$ is a solution to $x\equiv a\pmod m$ and $x\equiv b\pmod n.$ This completes the proof.