This usually happens through the party's primaries and caucuses. It's then confirmed through a vote of the delegates at the national convention. But if no candidate gets the majority of a party's delegates during the primaries and caucuses, convention delegates choose the nominee.