Answer :
It depends entirely upon the number of electrons in the valence electrons. There is no correlation between the position in the molecule and the number of bonds the atom forms.
The answer is: the atom with more valence electrons are in the middle of a molecule and it form more bonds.
For example, molecule hydrogen cyanide (HCN).
Lewis structure for hydrogen cyanide is H:C:::N:
Hydrogen has valence one (I), it means it has one single bond and electron configuration like closest noble gas helium.
Carbon has valence four (IV), it has four bonds (one with hydrogen and three with nitrogen) and full octet.
Nitron has valence three (III), it has full octet and electron configuration like noble gas neon (Ne).
Hydrogen cyanide has linear shape (the bond angles of 180 degrees).