Do ICAO and IATA codes ever change for airports in time? If they do, how often does it occur? I am developing an app for airports and I am thinking of setting the uniqueness of an airport through ICAO or IATA codes.
Yes it does happen.
A city can build a new airport, in which case it will usually get a new ICAO code, but will get the original IATA (city) code. For example, Oslo changed from Fornebu to Gardemoen - Fornebu is ENFB, Gardemoen is ENGM; the OSL code was Fornebu but uis now Gardemoen.
A city can rename its airport for political reasons, so again the codes are liable to change. Example 1 is New York - Idlewild KIDL was change to John F Kennedy KJFK Example 2 is Johannesburg - Jan Smuts International was FAJS, then renamed to Oliver Tambo International FAOR.
Yes. It's a pretty big deal so it won't happen often.
Changing the major airport for a city is a big reason. I think both Denver and Austin did this (new airport opened with a different code, then took over the old airport code).
Renames can also happen. JFK used to be IDL.