Bush v. Gore comes to mind here. Wikipedia provides the following timeline of the situation after the 2000 presidential election in Florida:
On December 8, the Florida Supreme Court had ordered a statewide recount of all undervotes, over 61,000 ballots that the vote tabulation machines had missed. The Bush campaign immediately asked the U.S. Supreme Court to stay the decision and halt the recount. Justice Antonin Scalia, convinced that all the manual recounts being performed in Florida's counties were illegitimate, urged his colleagues to grant the stay immediately. On December 9, the five conservative justices on the Court granted the stay for Bush, with Scalia citing "irreparable harm" that could befall Bush, as the recounts would cast "a needless and unjustified cloud" over Bush's legitimacy. In dissent, Justice John Paul Stevens wrote that "counting every legally cast vote cannot constitute irreparable harm." Oral arguments were scheduled for December 11.
More interesting for the purpose of your question is the section on 'relevant law'. Aside from the Equal Protection Clause, it names three excerpts of US law, the first two have a clear connection to elections (quoting from Wikipedia):
Article II, § 1, cl. 2 specifies the number of electors per state, and, most relevant to this case, specifies the manner in which those electors are selected, stipulating that:
Each State shall appoint, in such Manner as the Legislature thereof may direct, a Number of Electors ...
Section 2 of the Electoral Count Act, now codified in 3 U.S.C. § 5, regulates the "determination of controversy as to appointment of electors" in presidential elections. Of particular relevance to this case was the so-called "safe harbor" provision, which assures Congress' deference to states in their appointments of electors if done by a specified deadline:
If any State shall have provided [...] for its final determination of [...] the appointment of all or any of the electors of such State [...] at least six days before the time fixed for the meeting of the electors, such determination [...] shall be conclusive.
The first excerpt states that it is up to the state legislatures to appoint its electors. The second excerpt on "safe harbor" is described as follows in relation to the 2020 by the LA Times:
For the 2020 election, the states have until Dec. 8 — six days before the electoral college must meet — to count votes and settle all election disputes. If states can’t figure things out by that “safe harbor” day, the newly elected Congress gains the ability to determine the state’s winner when lawmakers meet to count electoral votes Jan. 6.
Back to your questions:
But can the courts actually help him to win and overturn the result in any state?
Possibly. One way to get there would be to prevent a state from providing its final determination of the appointment of all its electors before the safe harbor deadline.
If the final decision is with the electors it would seem to me that the best a court can do is provide a recommendation and surely it's the electors he should be petitioning rather than the courts.
It would be much easier to get the preferred slate of electors than it is to convince individual electors to change their vote. By locking in the states you won (making sure they provide their final determination by safe harbor day), and contesting the results in states you lose to the extent that the courts prevent the state from making that determination by safe harbor day, there could be a way for the courts to play a role in changing which electors get chosen.
Specifically, if it gets past safe harbor day and there are different slates of electors, there could be a replay of the 1876 election. Again from the [LA Times article]:
Hoping to avoid a repeat, Congress passed the Electoral Count Act of 1887, which gave states the safe harbor deadline by which they could resolve their own disputes without Congress getting involved. After that deadline, if state officials submit multiple sets of conflicting electoral votes, the U.S. House and Senate must agree on which set to accept. (If the chambers don’t agree, the votes certified by the state’s governor prevail.)
What power do the courts have in bringing about a certain result?
In the end, I think it all boils down to article II of the constitution which gives the state legislatures the power to appoint the electors. The courts, however, may be involved with interpreting what the legislature meant.
This was also a topic in the Bush v. Gore case. For example, from Wikipedia:
Bush also argued that the Florida Supreme Court's ruling violated Article II, § 1, cl. 2 of the U.S. Constitution. Essentially, Bush argued that the Florida Supreme Court's interpretation of Florida law was so erroneous that its ruling had the effect of making new law. Since this "new law" had not been directed by the Florida legislature, it violated Article II. Bush argued that Article II gives the federal judiciary the power to interpret state election law in presidential elections to ensure that the intent of the state legislature is followed.