In Elf, the shower scene wasn't in the original script, but it was ultimately added after director Jon Favreau learned that Zooey Deschanel was a good singer.
In an interview, Favreau said he wrote it into the script because Zooey's voice reminded him of Doris Day. He said it was old-timey and gave the film a magical feeling.