At the literal level, to do X with regard to Y, simply means take [due] notice of Y, with the strong implication that this affects how you do X, to at least some extent (you regard, look at, consider Y before deciding how to do X).
On the other hand, doing it according to Y explicitly states that your decision/action is in accordance, agreement, compliance with Y.
Consider a judge about to pass sentence on a child-molester, where the victim's parents have publicly called for the accused to be hanged...
1: Sentence will be passed with regard to the wishes of the victim's parents.
2: Sentence will be passed according to the wishes of the victim's parents.
In some countries it's possible the judge could say either of those, then sentence the accused to death by hanging. But in Britain (where we don't have the death penalty), #2 wouldn't really be a valid statement, since X (the judge) can't abide by the requirements of Y (the parents). If the British judge made the first statement, it would simply mean he took the parents' view into account (and almost certainly passed a more severe sentence that he might otherwise have done).
Turning to OP's three examples...
A: Since obviously there's no "official" rule book setting out exactly how kids should be treated at each different age, we can only interpret according to loosely (i.e. - the same as with regard to).
B: I think assigning a value to a variable X with regard to Y is slightly unusual phrasing, because I usually think of program code as following exact rules, not making judgements. If Y is the only thing affecting the assigned value, I'd say according to Y, but if other factors may also be involved I might say taking Y into account.
C: With building regulations, you normally comply exactly, so you act according to the rules. If you only do the work with regard to the rules, that might imply you're prepared to cut a few corners.