That's because...technically...the government mostly provides contracts to SpaceX to take their stuff to and from orbit. They're basically paying for a service...not investing in SpaceX's product development. Even though that is an indirect result of giving them those contracts.
It's like hiring a landscaper to do your lawn. They come with their own equipment, so even though they bought it using the money you pay them...you don't own any of it. They do.
Except that NASA is a nationally owned branch of the government. They answer directly to the executive branch and are funded by Congress. They are not a "company". They are a government agency.