They all go through the same code on the mod's side. Maybe it's the player's presence (affecting market refreshes and such) that make the difference?
(I've known about prefixes not changing for a while but never did figure out why. Maybe I'll look into it for next version.)
I tested some more and have a guess to why there is a difference.
When a player occupies a planet, unless it has the commerce industry the open market (probably) gets "deleted" together with its ship prefix data etc.
However when a player occupies a planet with commerce and then transfers, the open market is not deleted; The market will still have the same prefixes due to it inheriting the same market instance.
Both cases were tested with the same method (setmarketowner command on chicomoztoc with commerce and no commerce and then transferring to some other faction)
Additionally, adding commerce after the planet is transferred to the player and then giving it to some other faction caused the ship prefix ISS to remain on that open market. And doing this on a market with a military market caused the planet to have markets with 2 different ship prefixes.
I guess the fix for this would be to delete all the markets in the same manner when a player occupies a planet without commerce.