When William Shakespeare said, “All the world's a stage” in his play As You Like It, he used a metaphor. This figure of speech is used to compare two otherwise unconnected things like the world and a stage.
The Hunger Games Trilogy by Suzanne Collins is said to represent the competitive capitalistic system in which people are pitted against each other and only the fittest survive. It's a metaphor, but an extended one. It isn't obvious immediately.
This story is an allegory, which is an extended metaphor. An allegory represents a concept through a symbol that may share some similarities with whatever or whoever it represents.
Aslan, the lion, in The Chronicles of Narnia series by C S Lewis, is an allegory of Jesus Christ. Many instances make it easy to spot the comparisons. When Aslan sacrifices himself selflessly and is resurrected, it parallels what happens in the life of Jesus Christ.
Allegories, symbols, and metaphors transform an ordinary novel into a work of literature. Sometimes, one has to delve deeper to spot the deeper meaning in a book and the various levels in which it “works”. In The Hunger Games , The Capitol is said to represent the United States with its wealth and luxury, and the Districts are symbols of the poorer developing countries.
One can read an allegorical tale like George Orwell's Animal Farm and William Golding's Lord of the Flies , and enjoy it without grasping the allegory. While Orwell's work is about the Russian Revolution and its leaders, Golding's is about human nature.
Allegories are ubiquitous in literature and films. Watch out for them!