You need to understand that in order to run an app on an iOS device, you just need a valid provisioning profile.
You have two wildcard provisioning profiles, so technically both could work. However, you state that your provisioning profile was created with Signing identity A. First, confirm that your provisioning profile has only the Cert for identity A selected. Technically, a provisioning profile can be valid with multiple certificates.
If you confirm that your profile is not associated with the cert for signing identity, meaning the profile should not be valid if you signed the app with identity B, the other likely reason is that you already installed the app (or some other app) using the profile and signing identity A. If that is the case, there is a valid provisioning profile on the device that says your app should be allowed to run. I posted some more details about scenarios where the provisioning profile packaged with the app may be invalid / expired / etc. but the app will still run on the device in this post.
If you are expecting to use the code signing / provisioning profile to keep an app from successful install, you should have a dedicated, explicit bundle Id in your provisioning profile, along with a certificate specifically for that app ID. Then you can expire the profile and revoke the cert when you need to prevent the app from running on devices.
Edit: To check if this is due to an existing provisioning profiles, open Xcode, go to Window->Devices
Right click on the device in question and select "Provisioning Profiles", like this:

If you want to try it out, you can remove all the provisioning profiles from the device and try to re-install. If you really only have a provisioning profile that is configured to accept the signing identity A, and you sign the binary with signing identity B, it should not work.