When speaking at a political rally in support of a candidate running for Congress, the role that the President performs is that of a Party Leader. The President's role as a Party Leader involves working to advance the goals and interests of their political party, including supporting candidates running for office under the party's banner.
By speaking at a rally in support of a Congressional candidate, the President is helping to rally the party's base and drum up enthusiasm for the candidate's campaign.