How can the concept of a national identity both unite and divide people?
The concept of a national identity can unite those who fit the national identity and divide those who do from those who do not.
The "in group" can be strongly united by their national identity. We saw this, for example, when Germans were tied together strongly by their national identity in the Nazi years. More benignly, there are countries like Japan today where the people share a strong sense of unity. This brings them closer together than is possible in more diverse cultures like the US.
But national identities also divide people. In Nazi Germany, "Aryans" were divided from everyone else and the Jews were separated and treated in the most horrible manner imaginable. In Japan, the strength of Japanese national identity can serve to exclude people like Koreans who were born and raised in Japan but do not fit in to the national identity.
In these ways, a national identity both unites and divides people.