How TensorFlow will know if the prediction is true or false?
During the training process, the machine learning program is shown example inputs (in this case pictures of digits) and also what the answer should be for that input. That is how it learns the correct answer.
However, it does not learn an exact mapping between the input data and required output, instead it learns a series of patterns that generally map the input to the required value. The advantage of this approach is that it can perform the same mapping on new inputs that were not included in the training data but are similar (but not necessarily identical) to examples that it has already seen.