You are not passing the attention mask when doing logits = model(model_inputs) in the first sample. If you look at the model_inputs in the second sample, you will see it has several keys: input IDs and attention mask in particular. This second tensor tells your model the tokens to ignore because of padding, ans, as you observed, it yields to different results.
This is also explained in depth in the course 6.