The adenine molecule has atoms of Nitrogen and Hydrogen that stick out in just the right way and position to attract/bond to an Oxygen and Hydrogen of Thymine. It's kind of like how if you try to shake someone's left hand with your right hand, it just doesn't fit right, but if you shake their right with your right, then it fits together well. Similarly, Guanine can easily bond to Thymine because they have appropriately matched up atoms. Additionally, an A to T pair takes up exactly the same amount of space as G to C, which means DNA has a consistent width. If the wrong base gets somehow paired up, that makes the DNA bulge, and enzymes can detect that and will remove the mistake.You can look at the link I listed below to see what I mean.