Critical spin fluctuations and the origin of nematic order in Ba(Fe1−xCox)2As2