It somehow knows to do this at the moment you're furthest from being able to find a computer with iTunes. My iPod Touch did it when I was on the Pacific coast of Colombia for a month (note the complete absence of roads and towns along said coast).
Getting to a place where I could listen to music again involved an overnight trip on a cargo boat through pirate-infested waters.
But I suspect that was an edge case that Apple didn't have in mind when they designed that feature.