The prophecy is about Israel.
"Seventy weeks are determined upon thy people, and upon thy holy city..." 9:24
But this is not the only part determined in this prophecy. v26 "And after threescore and two weeks shall Messiah be cut off..." =7 weeks + the 62 makes 69/
So here ends the 69th week of the determined 70 weeks. Now, instead of telling about the final week, Gabriel begins to tell things as to determined desolations. These desolations are not determined to happen durng the 70 weeks. "...shall destroy the city and the sanctuary....desolations are determined."
Then later comes the final week. This week is what Daniel supplicated about at the start of chapter 9. It is when the he, that has more time left to desolate Jerusalem, finishes it, so as to come to the end of a prophecy that was foretold in Jeremiah.
Daniel 9:3 "...set my face unto the Lord God, to seek...by supplications..."
v23 "At the beginning of thy supplications the commandment came forth...understand..."
v2 "...the word of the LORD came to Jeremiah..."
Verse 3 shows that Daniel was confused so he began -- to seek by prayer and supplicatons, with fasting, and sackcloth, and ashes:" some help to understand the words written by Jeremiah the prophet.
Gabriel didn't say the commandment came at the time he prayed -but at the begnning of his suppications. When Daniel began to supplicate the commandment came forth to send Gabriel to him with the answer to the Jeremiah prophecy.