The gunman who killed 10 people at a grocery store in Buffalo, N.Y., is thought to have been motivated by racial hatred.