It comes from shared values, shared upbringing. We tend to think of race as biological, but race is also a socially constructed phenomenom. Ethnicity is usually more difficult to trace because when we look at someone, we can't immediately categorize them in a certain ethnic group. I have students who think that, because they are not African-American or Latino or Asian, they have no identity. Ethnicity allows for more inclusion.
Race is exclusion.
A classic example is Israel, where you have Ethiopian Jews, German Jews, Polish Jews, all kinds of Jews. The issue there is ethnicity more than it is race. Ethnicity is the glue holding that society together. The glue that holds us together in the United States is that we all perceive ourselves as Americans, though that may mean different things to different people. There is no longer a need to feel as though everyone's got to go into this big stew and become one big mush.