I believe the 2-letter codes are registered with the IATA and IATA has the right to assign the 2-letter code to a new carrier when a carrier using the code becomes defunct. Because of a boom in airlines, over the past decade, the 2-letter code has been expanded to include a letter-number combination (hence JetBlue is B6
ICAO assigns a three letter code (British Airways is BA
for IATA code, BAW for ICAO). It reserves the right to withdraw the code from an airline should that airline go out of business or withdraw from ICAO membership (I wonder if any ever does).
As for stock symbol, that is guided by the exchange that trades the shares of the stock of a company, and the stock symbol may be regenerated as well at the discretion of the stock exchange. However, like the ICAO 3-letter codes, the permutation possibilities are so great, one finds such regeneration as a rarity than the norm.