"What is the Electoral College?
The Electoral College consists of 538 electors. A majority of 270 electoral votes is required to elect the President. Your states entitled allotment of electors equals the number of members in its Congressional delegation: one for each member in the House of Representatives plus two for your Senators. Read more about the allocation of electoral votes.
Under the 23rd Amendment of the Constitution, the District of Columbia is allocated 3 electors and treated like a state for purposes of the Electoral College. For this reason, in the following discussion, the word state also refers to the District of Columbia.
Each candidate running for President in your state has his or her own group of electors. The electors are generally chosen by the candidates political party, but state laws vary on how the electors are selected and what their responsibilities are. Read more about the qualifications of the Electors and restrictions on who the Electors may vote for.
....
Most states have a winner-take-all system that awards all electors to the winning presidential candidate. However, Maine and Nebraska each have a variation of proportional representation. Read more about the allocation of Electors among the states and try to predict the outcome of the Electoral College vote."
https://www.archives.gov/federal-register/electoral-college/about.html
Are there restrictions on who the Electors can vote for?
There is no Constitutional provision or Federal law that requires Electors to vote according to the results of the popular vote in their states. Some states, however, require Electors to cast their votes according to the popular vote. These pledges fall into two categoriesElectors bound by state law and those bound by pledges to political parties.
The U.S. Supreme Court has held that the Constitution does not require that Electors be completely free to act as they choose and therefore, political parties may extract pledges from electors to vote for the parties' nominees. Some state laws provide that so-called "faithless Electors" may be subject to fines or may be disqualified for casting an invalid vote and be replaced by a substitute elector. The Supreme Court has not specifically ruled on the question of whether pledges and penalties for failure to vote as pledged may be enforced under the Constitution. No Elector has ever been prosecuted for failing to vote as pledged.
Today, it is rare for Electors to disregard the popular vote by casting their electoral vote for someone other than their party's candidate. Electors generally hold a leadership position in their party or were chosen to recognize years of loyal service to the party. Throughout our history as a nation, more than 99 percent of Electors have voted as pledged.
The National Association of Secretaries of State (NASS) has compiled a brief summary of state laws about the various procedures, which vary from state to state, for selecting slates of potential electors and for conducting the meeting of the electors. The document, Summary: State Laws Regarding Presidential Electors, can be downloaded from the resources/elections menu on the NASS website.
https://www.archives.gov/federal-register/electoral-college/electors.html#restrictions
There are more than a few constitutional legal scholars who disagree. Here are some articles expressing their opinions.
https://dailycaller.com/2019/02/04/natelson-popular-vote/
https://www.jurist.org/commentary/2012/02/william-ross-vote-compact/