State laws set out the grounds for contesting the election results by challenging them in court. Candidates can claim that election procedures weren't followed or that fraud was committed. It isn't enough to cite a generalized belief that something went wrong. Courts demand specifics.
Contest laws allow claims that fraud or irregularities changed the outcome of the election or at least put the results in doubt, by disregarding votes that should be counted or by counting votes that should be thrown out. Possible allegations include claims that ballots were cast by people who weren't qualified to vote, absentee or overseas ballots were wrongly tabulated, or voting machines were improperly programmed.