At first, Captain Marvel and Shazam! might seem as though they have nothing to do with each other besides the fact that they're superhero movies that came out around the same time. While we're not going to see a Marvel and DC crossover in the near future, these two characters do share a history together because of a copyright conundrum decades ago. In fact, Shazam was Captain Marvel way before Carol Danvers.
Originally published by Fawcett Comics, Captain Marvel became the bestselling superhero comic-book series of the '40s. Blessed by an ancient wizard, a young boy named Billy Batson only had to say "Shazam!" to transform into Captain Marvel and pick up super strength, endurance, speed, and other cool abilities.
While Captain Marvel was very popular, Fawcett stopped publishing the series in 1953. DC Comics noticed that Captain Marvel was an awful lot like its Superman, so it launched a copyright infringement suit against Fawcett. Perhaps winking at this contentious history, the Shazam! film includes a special reference to the Man of Steel himself.
Shortly after Fawcett stopped publishing the adventures of Billy Batson, Marvel Comics seized the trademark for Captain Marvel in the '60s so it could eventually have a character with that name. It would have several iterations of Captain Marvel, eventually settling on Carol Danvers.
In 1972, DC Comics picked up character rights from Fawcett for the original Captain Marvel. Billy's alter ego would still be called, confusingly, Captain Marvel. To avoid copyright infringement, the official title of the series just became the word Billy shouts to summon his powers: Shazam! DC Comics continued calling the character Captain Marvel for years until it decided to clear up the confusion by just naming the superhero Shazam in The New 52 in 2012. On Marvel's end, Carol Danvers went by Ms. Marvel until the very same year.
Since Captain Marvel and Shazam! came out with just a month between them, we're extremely grateful both franchises have sorted things out for clarity's sake.