First of all, the target settings will override the project settings. Build settings cascade down similar to CSS, and you can see this more clearly by enabling the "Levels" option when viewing the build settings for your target:

The green highlighted boxes show where the final resolved settings come from. So in the above screenshot you can see that the code signing is taken from the target settings. The values at the project level are ignored/overriden.
Generally you want to avoid these multiple levels of settings because it can get confusing and you have redundant information.
Your debug identity should almost always be set to "iPhone Developer" under the "Automatic Profile Selector" group, and should be defined at the project level (since it will be the same for all targets). You can delete this setting at the target level by selecting the entry in the target settings and hitting delete. The green highlight should now appear at the project level:

For your release and adhoc configurations, you probably do want to choose a specific signing identity at the target level, since you could theoretically have multiple application targets in one project with different settings. At the project level it's best to choose the generic "iPhone Distribution" (Automatic Profile Selector) option which will then be overridden.
When you build your application on the command line or archive it from Xcode, the application is built and signed with these settings, and an appropriate provisioning profile is embedded.
If you choose the "Distribute" option from the Organizer, this archived application can be completely resigned, which is why you are prompted again for a provisioning profile. This means a third-party developer can develop an application for you, archive it with their own signing information, send it to you, and you can then resign with your own private key and provisioning profile for the app store.
It should be possible to skip this final resigning stage, but I'm guessing too many people have made mistakes in the past so Xcode just takes over and does everything again for you.