The tendency for governments in the U.S. to purchase goods from private firms in voluntary transactions is largely a policy choice (in part, consistent with a distaste ideologically for communism) rather than a question of legal authority.
Eminent Domain
A government can force property that already exists and is owned by a private citizen to be turned over to it in exchange for fair compensation, though the process of "eminent domain" (also sometimes called "condemnation").
Usually, this is done in the case of real estate where location makes each parcel of real estate unique and the government and property owner are locked into a one buyer-one seller situation. But the eminent domain power includes the power to take personal property as well as real property.
Compelled Manufacturing
The government usually prefers to buy non-unique property in ordinary, voluntary market transactions, and rarely needs to compel a firm to produce a good. But, the government does have some power to compel a firm to produce the goods it wants to buy, for example, under laws such as the Defense Production Act of 1950.
A private individual probably couldn't be compelled to manufacturer goods for the government under the 13th Amendment to the U.S. Constitution's prohibition on slavery or involuntary servitude. But, soldiers can be (and have been historically) been compelled to do so, and corporations do not have 13th Amendment protections for themselves as entities.
In House Production
The government could also make goods itself rather than buying them from a third-party. State governments, for example, often use prison labor to produce license plates, since this doesn't set up a situation with the government is competing with private firms for something that they produce for the general public, with what amounts to slave labor.
There are five government owned, contractor operated, ammunition plants in the United States that belong to the U.S. Army.
Similarly, while the federal government usually encourages higher education with scholarships and research grants, it does operate several universities: several other military academies for which it is the only post-graduation employer of graduates, and one university for the deaf which the private market wasn't meeting the need for because its prospective student base was small and widely dispersed, and often has students who aren't affluent and have diminished post-graduation job prospects (on average).