Because they have same valency not valence electrons. those elements are arranged in a group which has same valence electrons because valence electrons determine the chemical properties of an element
hope it helps
2 4 2
This is because they have different number of shells.The periods depend on number of shells and not valency or valence electrons.both of them have same number of ve so they are placed in the same group not period.
1 5 1