The App Store doesn't know.
For most apps, all of the functionality to support different phone features is right there in the same version of the application. It detects the screen size and adjusts accordingly, for example. If you use iTunes to download an app, you can copy the same exact file to both an iPhone 4 and iPhone 5S and see for yourself.