Actually this is a common misconception. The territory of embassies always remains part of the sovereign territory of the receiving (host) country. The receiving country has duties under Article 22 of the Vienna Convention, indeed it must provide security to the diplomatic mission. It is also forbidden from sending its agents to the embassy without permission. But this does not mean that the territory becomes the sovereign territory of another country. If that were true the mission could not be expelled by the host country, which is not the case.
This also means that the laws of the host country apply in the embassy's territory and the host country can prosecute people for crimes within the embassy if they can capture them and these people do not enjoy immunity.
Some very few embassies (or other bits of territory) in the world were indeed ceded as sovereign territory to another state, in bilateral treaties the two states involved, centuries ago usually. That is an extremely rare situation and afaik was the case in Iraq.
This case in Iraq the unwillingness of the iraqi government to protect the US embassy seems to result from the crass way in which the US bombed iraqi forces, killing at least 40 iraqui soldiers, on so far unsubstantiated allegations that they had attacked a base where american mercenaries and some soldiers were stationed. PR wise this was as foolish as could be done, and made the iraqi soldiers themselves unwilling to protect the US embassy. It didn't help that the iraqi PM was only notified of this bombing immediately before it happened, and disregard when he attempted to block it.
Iraqis had been protesting their government and attacking iranian consulates. Now they are attacking the US embassy. Genius move, Pompeo et al!