Third time is a charm=The third attempt is assisted by the luck of number three
Third time is the charm=the third attempt is the luckiest because of the number three.
"A" works because it connotes the fact that luck is merely added by the number. 7 also could add a charm because of its occult significance.
There is no "the" charm, only ''a'' charm or some charms. You can have a charm bracelet and an occult amulet. Neither one is "the" charm. Both ward evil.
OED: Charm
b. Anything worn about the person to avert evil or ensure prosperity; an amulet.
1596 SPENSER F.Q. I. ii. 18 Curse on that Cross..Dead long ygoe, I wote, thou haddest bin, Had not that charme from thee forwarned itt. 1693 W. ROBERTSON Phraseol. Gen. 86 An Amulet or Inchantment and Charm hung about one's neck or wrest against witchcraft. 1832 H. MARTINEAU Life in Wilds vii. 84 Dame Fulton tied a charm round her neck to prevent her being wounded by any venomous reptile. 1832 LANDER Exp. Niger I. xi. 72 The horse's head was loaded with charms and fetishes. 1838-42 ARNOLD Hist. Rome (1846) II. xi. 407 He was very much afraid of thunder and lightning and always carried about with him a seal skin, as a charm against its power.
b. like a charm: wonderfully, perfectly. Also to a charm.
1845 Niles' Reg. 25 Oct. 128/1 The new rig works to a charm. 1851 T. A. BURKE Polly Peablossom's Wedding 40 Whenever he became refractory, his wife would stick her thimble on the end of her finger, and hold it up for him to look at{em}it acted like a charm! 1869 P. T. BARNUM Struggles & Triumphs viii. 123 He assured me that he should be able to give his imitations ?to a charm?. 1882 Philad. Press 19 Mar. (Th.), The freezing-out process was applied by Mr. Bliss to Cook, and it worked like a charm. 1934 F. N. HART Crooked Lane iii. 99 Bill Stirling gave her one the other night, and she said it worked like a charm. 1967 M. SHULMAN Kill 3 II. i. 59 ?It's worked like a charm,? said West.