How Neural Networks Extrapolate: From Feedforward to Graph Neural Networks