https://en.wikipedia.org/wiki/Captain_Marvel_(Marvel_Comics)...
The version in the upcoming film is also called Ms. Marvel.
- National Comics (the predecessor to DC) made Superman comics
- Fawcett Comics made Captain Marvel comics, inspired by Superman
- Fawcett's Captain Marvel and spinoffs became more popular than Superman
- National sued Fawcett, and in the lawsuit it came out that some Captain Marvel stories were direct copies of Superman stories with the characters swapped
- Fawcett settled the lawsuit and shut down Captain Marvel production
- Over a decade later, Marvel Comics started publishing their own Captain Marvel (a different character aside from the name) and got the trademark on the name
- DC, as successor to National, licensed and later bought out the Fawcett Captain Marvel, then added him to their own universe alongside Superman
That's how you get to a Marvel movie titled "Captain Marvel" featuring Captain Marvel, and a DC movie titled "Shazam!" featuring the other Captain Marvel, even though the now-DC one came first.
The gist is that when Captain Marvel was shut down, the British publisher came up with a knockoff called Marvelman, who then went through a comparable set of rights battles and name changes, becoming Captain Miracle, then Marvelman again, then Miracleman, then Man of Miracles (when eventually bought up by Marvel, weirdly enough).
Along the way, there was a really disturbing run in the '80s written by Alan Moore, which was out of print for years because of the rights battles, and also bits from Neil Gaiman and Grant Morrison. Oh, and a villain called Young Nastyman, who turns up in a Tenacious D song.
(NB: Look at the guest book)