Saddam Hussein's government and military were shaky when the war itself started, and absolutely no match for a modern, mobile, technologically advanced military like that of the United States. But occupying the country and toppling Hussein's government was the easy part, it's what the American military was designed to do. As Secretary of State Colin Powell said to Bush at the time, "You break it, you buy it", meaning the US was faced with the task of nation building once the initial conquest phase was over.
There were also some key mistakes made. The Iraqi Army was dismissed, but no effort was made to secure their weapons or to secure ammunition dumps in the early days, so an insurgency was in part created by American policy. Iraq is a complex country as well, with various competing factions, Shia Muslims, Sunni Muslims, Kurds in the north, former Baath Party members, all of which were armed and except for the Kurds, anti-American.
Insurgencies in general take much longer to fight than conventional conflicts.