The government promised to purchase massive quantities of Pfizer manufactured it to guarantee a market, they didn’t directly fund R&D.
I've heard government grants were involved?
Either way, guaranteed funds is still one hell of a profit motive to do the R&D and produce the medicine.