Donald Trump and his allies are laying the groundwork to contest a potential loss in November, stoking doubts about the election's legitimacy and preparing for post-election challenges.