If a civ spawns without any colors it can use, it just takes the first available color in the list from the editor. For example, Carthage has a Primary Color of Brown and a Secondary of Dark Red, Russia has Brown for both colors, Japan has Green and Dark Red, and the Aztecs have Green and Green. If all 4 are in the same game, one will be Green, one will be Dark Red, one will be Brown, and one will be whatever the first not-taken color is. Usually, it's one of the first few at the top like Red, Orange, or Yellow, but sometimes it can go pretty far down the list, and you'll get all 31 colors if you play a 31 civ game, unless it bugs up and gives two civs the same color. In my experience, that bug is most often caused by the Byzantines and Hittites, since they both have Primary colors (Dark Red and Teal, respectively) that other civs have as secondary colors (Carthage and Japan have Dark Red as a Secondary, Persia has Teal as a Secondary), which confuses the hell out of the game. The Byzantines and Hittites actually both have secondary colors (Red and Light Brown), but I've never seen the Hittites switch to Light Brown in games with Greece and Persia in them, and the Byzantines could switch to Red anyway because of how the game assigns colors, but normally, one of the other civs that has Dark Red as a Secondary color switches to Red or whatever the next available color is. It's not just them, it happens to other civs, too, especially since all of the C3C civs share both of their colors with other civs except Portugal (and technically, the Hittites, but see my above note on that)
It never happens in Vanilla, since none of the civs share secondary colors in Vanilla. PTW only has the combination of Carthage, Russia, Japan, and the Aztecs. C3C, though, has a lot of civs sharing secondary colors, and a lot of colors that aren't used for any of the civs that only show up if you're playing 31-civ games, like Dark Orange, or Mustard Yellow.