We are interested in the 2 square combinations. we want 2 square combinations which have 1 side in common. This is equal to the no. of sides in common. Count the no. of common sides , not the squares.
Each horizontal and vertical line ( except the ones at the end) will be a common side for 2 squares.