Well, it usually has a theme that ties it to the story. For example, if the story is about a hero's journey, the music might have a heroic and uplifting theme. The music also tends to be programmatic, which means it is designed to evoke an extra - musical idea, in this case, the story. Take 'Swan Lake' for instance. The gentle and flowing music for the swan scenes reflects the beauty and grace of the swan princess in the story. And it can have variations in tempo and dynamics to match the different parts of the story. In a battle scene in a story - based music, the tempo might be fast and the dynamics loud.
The Sound of Music has roots in a true story. However, it's important to note that for the sake of entertainment and narrative flow, certain aspects were fictionalized or adapted. The overall framework of the story is based on the experiences of the von Trapp family.