How are the electors for each party selected in the US presidential election?
The selections of electors vary from state to state, and from party to party. However, the two major parties in most states have adopted a fairly similar approach: State delegates associated the winner of a party's national convention appoint a slate of electors who pledge to vote for that party's candidate in the general election. The slate of electors associated with the candidate who receives the plurality of the votes of the general election in each state become the electors for that state; winner take all.
Nebraska and Maine do things differently. Those states have two statewide electors plus one elector for each congressional district. There have been multiple elections in Nebraska and Maine where one presidential candidate was the victor in the statewide election but lost in one of the congressional districts.
Regarding rogue electors, aka faithless electors, this has happened multiple times. Some states void the votes of those faithless electors (with or without a penalty), other states count the votes of those faithless electors (with or without a penalty). The US Supreme Court recently upheld state laws that penalize these so-called faithless electors.
It is up to the parties in each state how they nominate their Elector candidates. Sometimes it can be done at the state party's convention, sometimes it's done by the state party's central committee.
Electors going rogue ("faithless electors" being the term for such an elector) are very rare, and a matter for state law. There were ten faithless electors in the 2016 election, seven of whom were able to successfully cast a vote, and three who attempted to vote faithlessly but were replaced under the laws in their state.
In the century before that, there were a total of nine faithless electors, according to this list.