If you take out 5 socks and there are only 4 colours, you will end up with at least one pair in the same colour. The worst case is just one pair and the best case is two pairs and one odd sock. The best case means you have two pairs of socks in the same colour. Take the worst case. You have 3 odd socks. If you draw one sock it could be the missing colour, so you still don't have another pair, because all the socks you have are of different colours. But if you draw another sock, it must match one of the 4 you already have, so you have another matching pair. In all then, you will have drawn 7 socks to guarantee that you have two pairs.
EXAMPLE: Using R, W, K, B for red, white, black, blue, you draw BWKRW. So you have a white pair and BKR remain. You draw two more: WB. You have another pair, this time in blue. So you have two pairs: white and blue. The 7 socks you took were BWKRWWB. Any combination of 7 socks will give you at least two matching pairs. Note that the numbers of socks to draw from don't matter.