Why does this age calculation trick work?
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.