Jesus gained Nathanael’s attention by showing that he knew his character (1:47). Then Jesus showed that he knew Nathanael’s earlier actions, even though they had not met before.
This supernatural knowledge (knowledge beyond normal human ability) amazed Nathanael. He saw this as a sign from God and responded with faith.
Nathanael had witnessed a miracle. As a result, he made a strong confession about who Jesus is.