All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
What you have mentioned is one of the rhetorical styles of the Quran, and this is what is known by moving from the first person, or second person or third person into another pronoun, as a way of beautifying and refining the speech, and using different styles of speech. Al-Baydhaawi said: 'When the speech moves from one style to another, it renders it tenderer for the listener and makes him listen more attractively, as confirmed in rhetoric.'
Finally, it should be noted that Allaah, the Exalted, Says (what means): {Indeed, I am Allaah. There is no deity except Me.}[Quran 20:14].
Allaah Knows best.