I think the producer of a programme could request that something would be saved in the archive, if they felt it deserved to be preserved. A lot of stuff has been returned to the archives that was lost through copies sold to overseas countries. And I guess some things may just have been lucky, and somehow avoided being held next to a magnet.
Sometimes that didn't work!
There is the famous instance of Barry Letts asking for all 5 episodes of 'The Daemons' to be kept as an example of Dr Who of the time, but 4 VT episodes vanished, leaving Episode 4 on it's original VT plus film prints of all episodes too albeit in B & W. (Wasn't there a 90 min compilation held too?)
I think the Series 2 Dad's Army episodes disappeared due to David Croft being on holiday!(How did the 2 early It Ain't Half Hot Mum episodes end up getting wiped?)
Here's another question. Would a producer of the time, being aware of the various restrictions, space, cost, Equity rules etc, if he kept too much of his material, be penalised(for want of a better word) for unofficially breaking a rule? Did each producer have a set limit what could be kept in the archive of their material?
IIRC, someone from the Doctor Who Restoration Team asked Barry Letts in regards to saving The Daemons & I think he said he didn't ask for them to be saved.
As for the randomness of episodes going missing, it seems as if there was just a "grab & destroy" policy of deleting the tapes, especially when it came to Doctor Who, for example Episodes 2,3,5-8 survive of The Invasion yet 1 & 4 went missing, you then get odd episodes like Evil Of The Daleks (Episode 2 of 7 is the only surviving one) & The Faceless Ones with only episodes 1 & 3 of 6 surviving. It seems like there was no real agenda as to which tapes were wiped.
As for Equity, their rules were that any programme recorded could only be repeated once & had to be done within three years of the original transmission, reason being that equity thought that if they were repeated more than once outside those three years then it would effect actors jobs, etc. Ironic how in this day & age the same bunch of actors are used & programmes are repeated to death (I'm looking at you Dave).
It was a combination of Equity, costs of tape & space that resulted in the junking of episodes of programmes. In Doctor Who's case it could have all been avoided, had there had been better communications between the BBC Archives in London & BBC Enterprises. IIRC Enterprise junked their copies, once the international sales opportunities had been exhausted, in the miss-belief that the BBC Archives in London had every copy safely in their vaults. Oddly enough when the BBC were clearing out Villiers House in August 1988, when they came across Episodes 1 & 4-5 of The Ice Warriors, however where Episodes 2 & 3 have gone remains a mystery.