“Cat flap” and “cat door” entered the Oxford English Dictionary in 1957 and 1959, respectively, but the idea goes back much, much earlier in history. When agriculture began thousands of years ago, people noticed that feral cats didn’t eat grain but were pretty good at chasing down rodents and mopping up insects. So they installed little doors (or simple holes) to allow cats into granaries. This practice still continues today in a few places.
Modern-day cat doors, designed for pets, are much fancier. There’s typically a flap with weights on the bottom. Often they have springs to hold the door shut against wind and weather or have magnets on the edges for the same purpose. Some cat doors have a mechanism that allows them to be set to open in only one direction, for instance allowing a cat to come in but not go back out (although clever cats have figured out how to defeat this). Really deluxe models have a means of unlocking only for animals with the “key,” be it magnets in the collar or an implanted microchip.