Another consideration is that many US states are Gerrymandered to enforce a vote for a particular party. Most states are re-redistricted by an elected official or series of elected officials, and several states get gerrymandered for political biased in order to pick the electorate. This occurs in both parties, with the current opinion in discussions that the the Republicans do it more, but even pro-Democratic supports don't even side step that they control one of the worst gerrymandered states in the entire union with it's infamous 3rd congressional district (aka The Broken Wing Pteradactyl district), which cuts through four different counties and the city of Baltimore. The net effect is that in a state where the voters are registered 2 Democrats for every 1 Republican, Maryland's House Delegation has only one Republican out of 8 total representatives. If it was more representative of the population, it would look more like 5-3 or 6-2, depending on how the rounding is done.
In terms of the Presidential election, this is a horse of a similar yet different color. In the United States, the Popular vote does not decide the President (or if you want to push back against people who want it too, it does, but you have to win more popular votes). The U.S. uses the Electoral college which ranks the voting power of each state by it's total congressional delegation (each state gets an automatic 3 votes plus an additional X where X = House Reps - 1). In addition D.C. gets 3 votes and may never have more votes than the least populous state in the Union (D.C. currently has a higher population then at least two states, but it's not enough to merit an additional vote, so it doesn't really matter anyway).
Each state is allowed to delegate their Electoral votes any way they see fit. Baring Nebraska and Maine, every state with two or more electoral votes chose to use a winner take all system. Nebraska and Maine divide the votes such that winner of the popular vote takes 2 votes plus one vote for each congressional district they won the popular vote in (Maine has two so there could be a 3-1 split. Nebraska has five votes, so it can be split 3-2 or 4-1.).
As mentioned by her supporters, Clinton won the national popular vote (by 3 million votes... give or take), but Trump won more electoral votes (by a wider margin of total available. He also won more counties and more congressional districts). On paper this might seem like a violation of how a "Democracy works" at first, but the system is used in to prevent a few urban areas from controlling the larger rural areas. Like I said, Hillary only wins the election if it counts pure popular vote, any division smaller than purely national, she loses by wide margins. Even in a semi-direct democracy like Switzerland, the popular vote is checked by having it measuered against the Cantons vote (equal to states in terms of federalism). If it's popular with the majority, but not popular with the Cantons, it will lose there too.
And since you asked about race, this too is also balanced by the fact that the African American population represents about 12-15% of the national population. Meanwhile the Caucasian population is about 65% of the total population of the country. When combined with the Hispanic Vote (tends to Democrats, but there are significant sub-groups that swing Republicans, such as the Cuban Population who hate Castro and anyone who says he should be allowed to exist in any way and Conservative Catholics) This is around half of the majority vote still. The remaining ethnic minority populations also tend to Democrats, but this gets wobbley with Asian Americans who only recently started voting for Democrats more (it's only recently that there was significant American generation of Asians over Immigrant Asians. Most of the latter were either from very Conservative Cultures (such as the Japanese) or fleeing Communism regimes (Vietnamese, Some Koreans) or both (Chinese).
It should be worth pointing out that while I don't have the exact numbers in front of me, Hilary Clinton's poll numbers among African Americans took a dramatic dip of a few points while Trumps poll numbers increased far greater than the drop off in Clinton's and were the best numbers for that demographic for a Republican President in decades. While these numbers still had Hillary in the low 90s among African Americans and were only 1-3 points, the fact that Trump picked up a greater percentage can be worrying as some social commentators have speculated that a loss of only 20% of the African American vote would devastate the Democrat party (Though I have no factual number crunching to back this up at this moment. It's just a little discussed possible problem I thought was interesting to mention.).
As a rule, Americans will vote in block with like minded people, based on race, region, and need. But they are not historically a part of any particular party as the goals of the party change. And while people do talk about how the Republican party used to have the black vote up until the mid-20th century, the way particular states voted has shifted as well. Keep in mind that California was not the bastion of Democrats it is seen as now. In fact, for most of it's time as a member of the Union, California was a bit of a Swing state, with a strong period of Republican lean until 1952. For the next 10 Presidential Election Cycles, California would be a Strong Republican state supporting them for all but the election of Lyndon Johnson in 1964. California swung for Eisenhower (twice) Nixon (Thrice if you Considered his failed Presidential run against **KENNEDY!*, Five times if you consider his Vice Presidential ticket with Eisenhower, and 8 times if you consider his pre-1952 Congressional service as a two term representative and once as a Senator prior), Ford (Sure, Ford Pardoned Nixon, but, given how hardcore fanboy California was for Nixon at this point, that was a feature, not a bug.) Regan (twice for Governor of California and then thought he did such a great job, they thought he deserved a promotion and elected him President) and then voted for George H.W. Bush once before contributing to his re-election defeat to Bill Clinton. Only Barry Goldwater (who lost in a landside nationally) was to offensive to Califorina's sensibilities.
As I hoped it demonstrates, the U.S. may be bank voters, but they do changes parties based on the times and the platforms and issues.