To make a long story short, Shazam used to be known as Captain Marvel for several decades before DC finally changed his name to avoid confusion.
So, the comics, toys and various other media were called Shazam — even though the character was still Captain Marvel.
Pretty much anyone growing up with this character thought his name was Shazam anyway, so DC finally gave in and changed the name to Shazam in 2011.
Marvel trademarked the name for themselves in the ’60s, so when DC started publishing its own Captain Marvel comics in 1972, they couldn’t legally market them by that name.