Here is a possible explanation, Marty went back to save the Doc TWICE, we only saw the second. The first time he helped save Clara, but failed to save The Doc, he then returned to '55 or '85 and altered the
timeline in some weird way we didn't see in order that the Marty who was in the movie would manage to save the Doc.
Another possibility is that the Doc had the tombstone put in (with the addition as a joke or romantic gesture) in order to make sure that Marty would still come back, as without it he would not, in which case the tombstone WOULD be there since he would have died...