Allah wanted to demonstrate to the angels why he had made Adam u as the Khalifah and the merits of the intellect that He has honoured him with. So, He said: ﴿قَالَ يَا آدَمُ أَنْبِئْهُمْ﴾ “He said, ‘O Adam, inform them of their names.” that is, these things and their names.
If someone says: “These things had not been created or had not existed yet then.” We answer: “The origins of these things had already existed.”
﴾فَلَمَّا أَنْبَأَهُمْ بِأَسْمَائِهِمْ قَالَ أَلَمْ أَقُلْ لَكُمْ إِنِّي أَعْلَمُ غَيْبَ السَّمَوَاتِ وَالأَرْضِ وَأَعْلَمُ مَا تُبْدُونَ وَمَا كُنتُمْ تَكْتُمُونَ﴿
And when he had informed them of their names, He said, ‘Did I not tell you that I know the unseen [aspects] of the heavens and the earth? And I know what you reveal and what you have concealed.’”
Some of the exegetes say that the angels did not say these things out. Rather, they occurred in their souls. Therefore, it was an internal dialogue. However, since Allah U:
ُ﴾يَعْلَمُ خَائِنَةَ الأَعْيُنِ وَمَا تُخْفِي الصُّدُور﴿
“He knows that which deceives the eyes and what the breasts conceal.” [Surah Ghafir: 19], and
﴾فَإِنَّهُ يَعْلَمُ السِّرَّ وَأَخْفَى﴿
“He knows the secret and what is [even] more hidden.” [Surah Taha: 7],
He knew that these thoughts had occurred to the angels. So, He made them apparent and answered them while addressing the angels through them.
We cannot determine whether this interpretation or that interpretation is the correct one. However, the important thing here are the purposes and concepts found in these verses.