I always thought the prefix code was invented for the very purpose Kirk used it for in WoK.
I think it was basically just meant to be the equivalent of a password. Not specifically meant for taking over another ship, just for getting into a ship's computer system in general. After all, the name "prefix code" suggests it's just a code you enter before doing something else, e.g. an initial code string you put into a computer instruction to verify that you're an authorized user. So it wouldn't be something that was invented for a specific purpose, just a general, routine part of Starfleet computer security, which Kirk was able to take advantage of because he was going up against another Starfleet ship in the hands of people who didn't know routine Starfleet security protocols and didn't think to close that backdoor.