One of the points Criminal Defendant Trump makes is that a president is immune for prosecutions for act that are part of his duties as president, for example the look a Bush and the weapons of mass destruction.
How ever a president has no role to play in an election, contesting in an election is not part of a president duties and the job of running an election is done by the states with no involvement of the president
Criminal Defendant Trump was entitled to contest the election result, ask for audits and recount which were all done but no issues where found and then come safe harbour day the result is final. It was at that point that Criminal Defendant Trump embarked on illegal means to over turn the election result and that was not part of his duties as president