Your model works for single digits because it was trained on MNIST, which contains one centered digit per image. For multi-digit images like "1234", you must split them correctly into individual digits, preprocess each one to match MNIST format (centered, 28×28, normalized), and pass them separately to the model. If splitting, padding, or centering is off, the model misclassifies (e.g., "1234" becomes "3356"). Also, switch to a CNN instead of dense layers for better accuracy. Visualize your split digits to ensure they are clean and centered. Each digit must look like a real MNIST image for reliable results.