While trying to get contract of a particular type by "at address" that contract should be selected from the dropdown menu.
What happens in your case is that you get the contract of type "A" but it will still behave as contract of type "B".
What "at address" does:
It just provides an interface to the contract which is selected and which is expected to be deployed at the given address.
- It finds which contract is selected for the operation of "at address"
- It then finds the interface (ABI) of that contract from the code that is written in the current file.
- Generates hashes of functions.
- Displays each function name.
- Whenever a function is called, the transaction data is prepared according to the hash of the function and sent to the contract.
Now if the contract has the ability to respond to that data, i.e., carry out that function, you get the correct output according to the contract at that address.
Note: This should be used with caution because if not used properly, you might end up interacting with another contract.