Why do the DNA bases only pair with one other DNA base?

DNA works on the principle of complementary base pairing.

Adenine pairs with thymine and guanine with cytosine.

In case of RNA thymine is replaced by uracil.