I expect Sauron probably planned on it being a pretty quick siege, but you're forgetting something crucial. Aragorn used the palantir to cut off a large portion of Sauron's forces from the attack and to bring more Men in a surprise attack on the attackers.
Tor my part I heeded them not,’ said Gimli; ‘for we came then at last upon battle in earnest. There at Pelargir lay the main fleet of Umbar, fifty great ships and smaller vessels beyond count. Many of those that we pursued had reached the havens before us, and brought their fear with them; and some of the ships had put off, seeking to escape down the River or to reach the far shore; and many of the smaller craft were ablaze. But the Haradrim, being now driven to the brink, turned at bay, and they were fierce in despair; and they laughed when they looked on us, for they were a great army still.
(The Last Debate)
That night we rested while others laboured. For there were many captives set free, and many slaves released who had been folk of Gondor taken in raids; and soon also there was a great gathering of men out of Lebennin and the Ethir, and Angbor of Lamedon came up with all the horsemen that he could muster. Now that the fear of the Dead was removed they came to aid us and to look on the Heir of Isildur; for the rumour of that name had run like fire in the dark.
‘And that is near the end of our tale. For during that evening and night many ships were made ready and manned; and in the morning the fleet set forth.
(The Last Debate)
Aragorn, at least, believed Minas Tirith would fall without his assistance:
“Yet to the Harlond we must come tomorrow or fail utterly.”
(The Last Debate)
In addition, Sauron had many more forces he did not deploy in his assault, possibly - probably? - because of him speeding up his plans. Aragorn and Gandalf recognized that military victory against Sauron was impossible. Sauron was probably not terribly desperate that his assault succeed in the first place; he was just concerned about cutting off Aragorn's rise to power.
‘Hardly has our strength sufficed to beat off the first great assault. The next will be greater. This war then is without final hope, as Denethor perceived. Victory cannot be achieved by arms, whether you sit here to endure siege after siege, or march out to be overwhelmed beyond the River. You have only a choice of evils; and prudence would counsel you to strengthen such strong places as you have, and there await the onset; for so shall the time before your end be made a little longer.’
(The Last Debate)
‘I did so ere I rode from the Hornburg,’ answered Aragorn. ‘I deemed that the time was ripe, and that the Stone had come to me for just such a purpose [to show himself to Sauron]. It was then ten days since the Ring-bearer went east from Rauros, and the Eye of Sauron, I thought, should be drawn out from his own land. Too seldom has he been challenged since he returned to his Tower. Though if I had foreseen how swift would be his onset in answer, maybe I should not have dared to show myself. Bare time was given me to come to your aid.’
(The Last Debate)
Without Aragorn, the situation was dire. Even before the ships arrived, it looked like all was lost:
It was even as the day thus began to turn against Gondor and their hope wavered that a new cry went up in the City, it being then mid-morning, and a great wind blowing, and the rain flying north, and the sun shining. In that clear air watchmen on the walls saw afar a new sight of fear, and their last hope left them.
(The Battle of Pelennor Fields)
So instead of surrounding the enemy, Sauron's forces were themselves surrounded:
East rode the knights of Dol Amroth driving the enemy before them: troll-men and Variags and orcs that hated the sunlight. South strode Éomer and men fled before his face, and they were caught between the hammer and the anvil. For now men leaped from the ships to the quays of the Harlond and swept north like a storm.
(The Battle of Pelennor Fields)
Even so, it was not an easy battle:
Hard fighting and long labour they had still; for the Southrons were bold men and grim, and fierce in despair; and the Easterlings were strong and war-hardened and asked for no quarter. And so in this place and that, by burned homestead or barn, upon hillock or mound, under wall or on field, still they gathered and rallied and fought until the day wore away.
(The Battle of Pelennor Fields)
So the reason things didn't go quite Sauron's way was because he accelerated his plans, and Aragorn cut off part of his army and supplied unexpected reinforcements to Minas Tirith that would have otherwise been stuck defending other parts of Gondor. And Aragorn was only able to do this by cheating, by using a palantir and wresting it away from Sauron - something even Denethor was not able to do. He otherwise was pretty well set. Even after the battle, he was in an excellent position.
Sometimes no matter how well laid your plans are, they just don't work out. I don't think Sauron made any particularly grievous errors here.