The Keycards are found in all episodes from the Invasion of the Vorticons series. They are used to unlock and open doors of the same color as the card. Cards come in four colors; yellow, red, green and blue, with each card having the letter A, B, C or D written on it in SGA. There is some indication that Keen 1 was to feature a "multipass" keycard that opened any door, but this was later abandoned. The tile is still in the Keen 1 tileset.
When a door is opened, it removes the keycard used from Keen's inventory, even if Keen has acquired two or more of those cards (a fact useful when modding levels). Keen loses all keycards he has if he dies, or when exiting a level. All keycards encountered can be used, but not necessarily to complete the game.
Keycards are probably a Vorticon invention, as they can be found in their Vorticon Mothership and in Vorticon VI. The keycards in Mars were probably put there by the Vorticon Guards stationed at the planet.