Look there are extreme and odious examples of various forms of nationalism run amok. But they represent a small minority of how nationalism plays out in the political arena. Overwhelmingly nationalism is a force for good that enables complex nation states to form, stabilize and thrive.Today’s white supremacists also claim to be nationalist, but they obviously are not. They use nationalism as a cover to hide their brand of hate and ignorance.
Nationalism works because it doesn't go against human nature it works alongside our nature. Humans are hardwired through evolutionary biology to be tribal in nature. Nationalism through the concept of patriotism enables practical manifestations of the nation state from humanity's tribal foundation.
In contrast socialism & communism go against basic human nature. They defy evolutionary biology to try to make us what we aren't, That's why they fail and we're yet to see a fully successful communist or socialist state. On the other hand nationalist states are the norm and have been mostly very successful - including the USA.
Nationalism is also flexible. It can coexist with and enhance democracies, constitutional republics and even monarchies.