Two bodies determine different codes. I believe it's IATA, which stands for International Association of Travel Agents (or something to that effect) that determines the two-letter airline code. The airport designator is a combination of the ICAO and the local governments.
AARPA (similar organization to IATA) designates three-letter codes for airlines, but they are infrequently used.
Vanguard: IATA: NJ, AARPA: VGD
America West: IATA: AW, AARPA: AWA
Southwest: IATA: WN, AARPA: SWA
United: IATA: UA, AARPA: UAL
Those who fail to learn history are doomed to repeat it in summer school.