There have been several cases of this, especially of actors who later became iconic in that role
Jeremy Brett – Regarded by many (including me) as the quintessential Sherlock Holmes in the Granada TV/WGBH series. But he had earlier played Dr. Watson to Charlton Heston’s Sherlock Holmes in Crucifer of Blood. It’s hard to imagine Brett as Watson, having him cemented in the Holmes role, but then again, it’s hard to imagine Heston as Holmes. Or Brett as Freddy Eynesford-Hill in My Fair Lady, for that matter.
David Suchet – He’s performed at Hercule Poirot on ITV (and PBS and A&E in the US), doing every single Poirot story Agatha Christie wrote. He also read several of the Poirot stories on audio. He seems to be as quintessential playing Poirot as Brett does doing Sherlock. I even like him better in the role than Albert Finney. No one else seems to do the role justice (sorry Kenneth Branaugh, Peter Ustinov, Tony Randall, Alfred Molina, et al.). But he apparently first appeared as Poirot’s foil, Inspector Japp in Thirteen at Dinner, opposite Peter Ustinov as Poirot (Ustinov, according to Suchet, suggested that Suchet could play the role).
Bela Lugosi – When they adapted the radio character Chandu the Magician (1932-3) to the movies in 1933, Bela Lugosi played the villain Roxor opposite Edmund Lowe as Chandu. The next year the character appeared in a 12-part serial, but this time with Lugosi playing Chandu. I think it’s a unique case of Lugosi, who often played the villain, switching to a role as hero he had originally been a villain for.
Keye Luke – The perpetual actor who first became famous as Lee Chan, “Number One Son” of detective Charley Chan in a series of movies made by Fox (and later continued by Monogram), eventually played Charley Chan himself – sort of. He voiced the character in the TV cartoon series The Amazing Chan and the Clan Chan. He was evidently the first actor of Chinese descent to play Chan. Much earlier, Luke had played another Chinese detective, Mr. Wong (a role originated in the movies by Boris Karloff) in Phantom of Chinatown (1940), the first actor of Chinese descent to fill that role, as well. There were supposed to be more, but the pulled the plug on the series after the first Keye Luke film.
Many other cases exist of well-known actors playing non-lead roles stepping into the lead position, but that’s a little different from the cases cited above (Phil Silvers , for instance, turned down the role of Pseudolus in A Funny Thing Happened on the Way to the Forum, then played Marcus Lycus in the film version, then played Pseudolus in the Broadwat revival.