Shazam is a nickname given to a character of Billy Batson in the comics Captain Marvel. He inherits from the wizard who is old and wants a successor to continue fighting evil in the world. The name Shazam is actually an acronynm for six legendary greek heathen gods. Every letter there represents a god.
They are arranged as below,
S – Solomon
H – Hercules
A – Atlas
Z – Zeus
A – Achilles
M – Mercury
Solomon represents wisdom. Hercules was a god of strength while Atlas was representing stamina. Zeus was for power, Achilles for courage and Mercury represents speed.
In the comic book Captain Marvel Billy is named Shazam and inherits the powers of each god. When Billy the character in the comic books calls on the gods he receives superpowers from the gods / elders in a bolt like lightening.
Captain Marvel a character from Marvel Comics was not always named Shazam but later was named so after marvel comics bought the name from its original owners.