Altering or touching a file does not always update the parent directory modification time? I've got two source code directories (different programming languages) and I've noticed that when I alter source files in language A the direct parent modification time also updates. However, in language B, altering sources does not seem to update the parent directory modification times whatsoever. 

Honestly, this feels quite weird to me and I can't find a pattern or reason for this. Is this something related to MacOS only? I don't recall every seeing this behaviour in Linux systems.

Can the files have some kind of attribute which tells the OS how to update the parent directories?

I'm on High Sierra using a zsh shell.
Your observations seem to be off. In this respect macOS works the same as Linux - the modification time for the parent directory change when you add, remove or rename files/subdirectories in that directory.

The modification time is not changed when you alter the contents of files. Neither on macOS nor on Linux.