Dress codes are usually set to formal in order to mark that the representatives are not representing themselves (by not allowing personal style - even one that mimics their constituents). That is: the anonymity of uniforms instead of allowing personal style underlines how the person is merely a representative and not there in their own capacity. The most extreme version of this is of course robes and wigs in some courts.
Like everything else, this is about to change (as it is looking increasingly weird) but that doesn't mean the underlying idea is crazy.