Ok, thinking about it a bit more, there is also the existing M5 East which is being handed over, so is probably closer to break even for the government. Here is how you could think about it:
Government has invested $3.6b in equity, as well as the M4, M5 East and M5 West. They will also make $5.3b in capital contributions to Stage 3, Rozelle Interchange and Sydney Gateway. So that is a total of $8.9b plus the existing roads as either equity, capital grant or infrastructure asset contribution.
In return, they have ended up with a company which has $18.3b in equity and a bunch of debt. They have sold 51% of the equity for $9.3b, so this effectively values the existing infrastructure assets contributed at a total of $9.4b, or $7.9b if you account for the $1.5b grant from the Federal Government.
Effectively all of the profit that the NSW just made is actually just payment for the existing toll roads they contributed. Still, no net impact on the budget and gaining value from those existing assets that can now be spent elsewhere is not a bad outcome.