Players give their PCs consistent personalities without (at most tables) the GM having any authority to step in and override a player's conception of his/her PC. Likewise, at many tables, for cohorts and henchmen. Why are moral codes, and divinities, in a special category?
Because they're part of the world/setting which are represented by the GM. As I've said before alignment is not a condition on individual PCs and NPCs. It is, as far as D&D goes, part of the fundamental forces of the universe; Gravity, Electromagnetism, Weak Nuclear, Strong Nuclear, Good, Evil, Law, and Chaos. If a character's behaviour is Chaotic (from the perspective of the universe) then the character is Chaotic no matter how much they consider themselves Lawful.
A player is free to assign any moral code they wish to a character, but where that code falls in terms of alignment is the province of the GM. Players can provide input and justification for why a particular action should be one or the other but the final call is made by the GM.