DC sued Fawcett comics into oblivion because Captain Marvel had become more popular than Superman. The hefty legal fees combined with declining popularity of cape comics in general caused Fawcett to then go out of business. DC then bought Fawcett's characters, not because they wanted to use Captain Marvel but because they didn't want someone else buying the Captain Marvel rights and then once again risking CM becoming more popular than Superman.
Since DC had no interest in actually using Captain Marvel and was just trying to keep other people from using him, the Trademark lapsed from lack of use. Marvel, realising that the Captain Marvel name was now up for grabs, decided to make their own Captain Marvel in the 60s. By the time DC decided to actually start using Captain Marvel/SHAZAM! in the 70s, Marvel had already fully secured the name for over 10 years.
Since Trademarks only effect the names and branding of products, this meant that while DC could still use Captain Marvel and continue calling him that, they couldn't name any comics "Captain Marvel" which is why all of DC's Captain Marvel comics were called "SHAZAM!" instead. Because his comic was always called SHAZAM!, this created the problem where the average person had the mistaken impression that he was named Shazam. Once the New 52 happened, they decided to just rename him to Shazam to avoid this confusion going forward.