... it's complicated. And tied to a great many crappy events. But in summary...
Around the time of Infinite Crisis, the hostless Spectre declared war on magic, thanks to Eclipso(possesing Jean Loring). Part of the fallout from this was the apparent death of Shazam in combat with the Spectre, and Billy having to take his place as the Guardian of the Rock of Eternity.
The Spectre's rampage was apparently also heralding the next Age of Magic, which meant the way it worked shifted. In the case of the Marvel Family, Freddy and Mary spontaneously lost their powers. (See also, the Black Mary trainwreck. No wait, on second thought, don't.)
We then had the 'Trials of Shazam' mini, in which Billy fully developed into his role as replacement for the wizard Shazam, being bound to the Rock, and empowering Freddy as his champion. Oh, and the mini had some fluff about the power of Shazam being derived from a set of gods of magic unrelated to the actual Greek-Roman mythological gods and hero set, save their names.
As of late, in JSA, the wizard Shazam is back from imprisonment, has forcibly depowered Billy and Mary, turned Isis and Black Adam into statues, and vanished, noting that Freddy was next on the list.