More efficient US state codes
Jelly, &nbsp;13&nbsp; 12 bytes

907ị;⁸Qḣ2ṢŒu


A monadic link taking and returning lists of characters.

Try it online! or see a test suite

How?

907ị;⁸Qḣ2ṢŒu - Monadic link: list of characters, state    e.g. Alabama   or   Kansas
907          - literal 907
   ị         - index into state                                b              K
     ⁸       - link's left argument, state
    ;        - concatenate                                     bAlabama       KKansas
      Q      - de-duplicate (unique by 1st appearance)         bAlam          Kans
       ḣ2    - head to index 2                                 bA             Ka
         Ṣ   - sort                                            Ab             Ka
          Œu - convert to uppercase                            AB             KA


Indexing in Jelly is 1-indexed and modular, so the 907th index of something of length L is the (907-modulo-L)th item. For example for "Alabama" the length is 7 so the item at index 907 is the (907-modulo-7)th, and 907-modulo-7 is 4 (907 = 129 * 7 + 4), so the item at index 907 is 'b'.

907 is the first positive index at which the state abbreviations using index 1 and that index over all of the 50 states become unique.

State names, including their spaces, are of length 4 through 14 inclusive, and 907-modulo-6 is 1 (whereas for all other lengths the value is not 1). This means that if we were to use the 1st and 907th characters for the abbreviations that Alaska, Hawaii, Kansas, Nevada, and Oregon would be AA, HH, KK, NN, and OO respectively - this is not acceptable for Hawaii, Kansas, or Nevada; so an adjustment needs to be made; this is the reason for the concatenation, de-duplication, head to index 2 and sort, this makes Alaska, Hawaii, Kansas, Nevada, and Oregon become AL, HA, KA, NA and OR respectively and does not collide with existing state abbreviations.