Professional chess players or experienced tournament players rarely allow their opponent to checkmate them. Instead they gracefully resign when the situation is hopeless.
For players below that level, it is better not to be too fast to resign. When the situation becomes bad, the first question to ask ourselves is if the situation is really that bad. There could often be hidden resources that could change the course of the game. For example we may be down in material, but we may have a pawn that threatens to promote and if the opponent tries to stop it, they may need to give us back some material.
Even if the position is objectively lost, there is no guarantee the opponent will play the best moves. Quite often a player in a superior position gets carried away and throws caution in the air. Or gets frustrated if we offer a stubborn resistance and our opponent fails to convert a good position to a winning one.
Of course there are cases really hopeless, such as when we have a lonely king and our opponent has at least an extra rook, and there are no stalemate tactics to save us. In such a situation we should gracefully resign.