What is the main factor that determines how atoms combine?

What determines how atoms (and molecules) combine is their electron configuration. In particular, what matters most is what the number (and arrangement) of electrons in what is called the valence shell of the atom. These are the outer-most electrons, and it is these that determine how things react and combine with other atoms and molecules