Why does this age calculation trick work?
The trick works like this: Take the current date in the format yyyymmdd and subtract it with your date of birth taken in the same format. Drop the last four digits to get your age.
For example, I was born in August 20th, 1994. Today it is July 13th, 2015.
$$ 20150713 - 19940820 = 209893\\ \textrm{Dropping the last four digits,}\\ \textrm{My age}=20 $$
I can understand subtracting two years, but how does crafting these numbers with month and day make it more accurate?
Subtracting the month and day lets you take into account whether you've had your birthday this year. If you have had your birthday, then you can just skip the month and day, they don't affect the two years at all (do the subtraction by hand to see this more clearly). If you haven't had your birthday yet, then the process of borrowing will subtract a year for you.
$$\large\begin{align*} \hphantom{-}(\mathsf{year}_1)(\mathsf{month}_1)(\mathsf{day}_1)\\ -(\mathsf{year}_2)(\mathsf{month}_2)(\mathsf{day}_2) \end{align*}$$ is equal to $$\large\begin{cases} \hphantom{{}-1}(\mathsf{year}_1-\mathsf{year}_2)\Box\Box\Box\Box&\;\textsf{if }(\mathsf{month}_1)(\mathsf{day}_1)\geq (\mathsf{month}_2)(\mathsf{day}_2)\\ (\mathsf{year}_1-\mathsf{year}_2-1)\Box\Box\Box\Box&\;\textsf{if }(\mathsf{month}_1)(\mathsf{day}_1)< (\mathsf{month}_2)(\mathsf{day}_2)\\ \end{cases}$$
You just have to check two cases, if $mmdd$ of the day you where born is more than current $mmdd$ then the first $4$ digits will be $yyyy-1$. If $mmdd$ of the day you where born is less or eqaul to current $mmdd$ then you get $yyyy$ as answer. Which is correct in both cases.