Most of this question is a spoiler. The first sentence is about the first few minutes, but everything else is about Columbo finding out.
In Columbo, season 3, episode 5, Riley Greenleaf gets a hired hand to kill Alan Mallory. He asks the (rather stupid) killer to “drop” a key to Mallory’s office, because he wants it to appear as if the killer had wanted to frame him for that murder. Since he owned the office he had rented to Mallory, he naturally had a copy of that (first) key. Later, Riley kills the hired hand. However, Mallory had previously changed the lock, and Columbo finds out that the dropped key could not have opened the office. In fact because of the heat and the malfunction of the air-conditioning, Mallory had left the door open and the killer did not have to (vainly) try to use the key he “dropped” after the murder. Columbo discovered that fact, but neither the hired hand nor Riley knew about it. Columbo tells Riley, and only Riley, that Mallory had changed the lock.
In order to maintain the pretense that the hired hand had premeditated the murder alone, when Riley kills him, he puts on the latter's keychain a key which he believes to be the one for the “second” lock, the one Mallory had got installed. It is not clear how Riley thinks the hired hand might have gotten hold of a copy of that lock. But that was in the past, unprovable one way or another. One could suppose the killer had sneaked in at some time when Mallory’s keychain was unattended and made an imprint, after all.
However, in the meantime, Columbo has got the lock changed again and the key on the killer’s keychain is in fact the one to the third lock, installed after the murder, so the hired hand had certainly not got it himself. That proved Riley’s implication in both murders (there was another proof, as well).
But how did Riley get hold of a copy of the key to this third lock (or to the second one, either, had Columbo not got it changed) ? Did Columbo give it to him, claiming it was the key to the second one ? After all the premises belonged to Riley, he had a right to have the key, eventually. But while the investigations were still going on ?
If it is the case, I missed that part.