The problem here is that ballots are already out and millions of people have already voted. At this point it seems impossible for candidates to come up with a new name to replace a name on the ballot without starting the whole election process over, which is not possible in the 30+ days before election day. Congress could pass a bill delaying the election but I find it hard to believe it would do so.
While things are not certain, what’s most likely that the election would take place on time with the deceased or incapacitated candidate’s name on the ballot, and then there would be a question if legislatures would allow presidential electors of each state to vote for someone other than the deceased candidate. Only some state laws provide for this eventuality. (Update: Some states provide that the votes for a named replacement are counted.) Or perhaps the legislatures would seek to appoint electors directly. This could lead to a whole lot of mischief if, say, the Pennsylvania Republican legislature tried, over the Democratic governor’s objection, to appoint electors to vote for Pence (if it were Trump who could no longer be a candidate) despite a vote for the people of Pennsylania for Biden over Trump.