If you're not sure "why" the difference exists, the D40 doesn't have an internal autofocus motor like many cameras do.
So, anytime a lens doesn't have it's own autofocus motor, it won't autofocus on your camera. So if you buy lens in the future, just check to make sure it has an autofocus motor. It's called a bunch of things, often something like Ultra Sonic Motor, or something along those lines.