Eventually they learn from experience that, while material is important, it doesn’t matter how many of your opponent’s pieces you’ve captured if your king is getting checkmated. Even the scale of material values is full of exceptions based on the type of position on the board. For example, a well-placed knight can be worth as much or more than a rook with limited scope.