I do know that writers can suggest actors, Clegg was written specifically with Peter Sallis in mind for example, and thus very often the same troupe or parts of it appear in different shows: hence some of the Hi de Hi cast appeared in Oh Dr Beeching, for example as there was a common elelment in David Croft co-writing it.
As many of our clasic comedies were written by a small handful of people, David Croft and Jimmy Perry collaborated on a number for example, it is not surprising that the same actors turn up.
Also if you are a good actor, you will get more parts. Who remembers the early Frank Thornton in the Hancock classic "The Blood Donor" and I think June Whitfield was nurse. They both have had a good career.
Some actors seem to do better at comedy, thus are often seen in such roles, and example would be Stephen Lewis who has portrye some fine comic stereotypes such as Inspector Blake of 'On the Buses', as well as Smiler in SW.