I don’t know if there is a good answer to your question @AshlynM. It’s a good question but I’d say it’s just one of those creative decisions. The director (or whoever makes that decision) has something in their mind and looks for music that fits OR commissions someone to produce a piece of music that fits.
The film’s genre or the era portrayed will or may influence the style of music (i.e. whether it’s jazzy or sad). They’ll want a piece of music that evokes a particular mood. So Samuel Barber’s Adagio for Strings is at least part of the soundtrack for Platoon. It’s mournful and makes you feel sad and I think, rather desolate. Where the theme to The Great Gatsy does evoke the 1920s, but there’s a sadness about it (and the story). The music to say Saw is a dramatic and I find it quite jarring. Or listen to the music for Wolf Creek. Remote areas of Australia are very isolated. So this music evokes that lost, alone, hopeless, spooky feel.
So the short answer is, they choose music that will evoke a mood. I would guess they’d test music too (if they have the funding). Have people listen to it and explain how it made them feel. I’m not in the film industry so I can’t confirm this. I’d be surprised if big budget films didn’t do this.