You see a trailer for an upcoming film, with really cool music that you can't identify. Well, please don't ask me. Finding out is sometimes impossible. If it's that thing in the ads for School Ties, Clear and Present Danger, Rob Roy, and a million others, it's Come See the Paradise by Randy Edelman, on a Varèse CD, the single most overused piece of trailer music.
How does music from some movie end up in an ad to a totally unrelated film? It's simply licensed and used (yes, the composer gets paid). Other times original music is written for trailers—sometimes this is a rip-off of some other piece of music, and sometimes existing music is "sweetened" with original overlays.
Movie trailers once featured the music to the actual film being advertised, but no longer. They are now in the domain of the marketers, who will use any piece of music as long as it sells the movie. If you are going around drooling about what that cool piece of 20-second action music or romance music was in the ad to such and such a picture, the Man has you just where he wants you—snap out of it.