To add a bit to the previous answer:
a) The government funds the projects if it provides the money directly to the contractors or entities who do the actual work.
b) In the case of underwriting the government works with an investment bank to issue municipal bonds to investors who then provide the necessary funds. The government guarantees repayment to the investors plus interest which the bonds carry. Payment of principal is due at bond maturity.