Logic behind problem related to LCM. This might be a stupid question, but I am not able to find any good explanation of this on the internet. Suppose there are two numbers $28$ and $32$. Now, we need to find the smallest number that divides these two numbers leaving remainders $8$ and $12$ respectively. One solution I found was that we first find their LCM, i.e $224$, and then subtract $20$ from it, because $32-12 = 20$ and $28-8 = 20$. But why are we doing this? 

You can write your conditions as looking for an $n$ such that
$$n \equiv 8 \pmod {28}\\n \equiv 12 \pmod {32}$$
This is equivalent to 
$$n \equiv -20 \pmod {28}\\n \equiv -20 \pmod {32}$$
Which shows why subtracting $20$ from the $\operatorname{LCM}$ works in this case-it is because your desired remainder is $20$ less than your moduli.  If the conditions were 
$$n \equiv 4 \pmod {28}\\n \equiv 12 \pmod {32}$$
You couldn't find a solution that way. To have a solution, all the desired remainders must be equivalent modulo the $\gcd$ of the moduli.  Here the $\gcd$ is $4$ and they do.  Then you are guaranteed that a solution exists by the Chinese remainder theorem and a couple ways to find the solution are given in the article.
