The only time you can be so sure you've chosen 2 brown socks is when there are no more white socks and black socks. This means that to be 100% sure that you have chosen 2 brown socks you have to choose the 12 white socks and the 18 black socks and only then can you choose 2 brown socks without looking. Therefore, the total number of socks to choose from is:
Total number of socks = 12 white socks + 18 black socks + 2 brown socks
Total number of socks = 32 socks
A total picking of 32 socks is necessary to be sure without looking that 2 brown have already been chosen that way.