The TVA Cases seem to have established in practice, although perhaps not fully in legal theory, that the Federal Government may compete with private enterprise.
Specific laws may prohibit or restrict such competition in particular fields, as other answers suggest.
In TENNESSEE ELECTRIC POWER CO. et al. v. TENNESSEE VALLEY AUTHORITY et al. 306 U.S. 118 (1939) it was argued by a group of companies that generated and distributed electric power that the US Federal government, in creating the Tennessee Valley Authority (TVA) and, through the TVA, competing with them in the creation and distribution of electric power, was acting unlawfully. The appellants claimed that their property was being taken, contrary to the Takings clause of the Fifth amendment, that the policy of the TVA amounted to federal regularization of matters properly under state control, and that the act creating the TVA was unconstitutional as being outside the enumerated powers of Congress. The made some other claims as well.
The US Supreme Court denied that the appellants had standing to challenge the overall constitutionality of the act. On all other issues, the Court ruled against the appellants on the merits. It discussed extensively the issue of competition by the government or a government-sponsored entity. It held that such competition is lawful, does not amount to a taking of property, and does not constitute regulation of rates simply by providing services at lower competing rates.
In the earlier related case of Ashlwander v. Tennessee Valley Authority 297 U.S. 288 (1936) the Court held that the construction of the Wilson Dam was lawful under the War and Commerce powers, and that disposal of the power generated by it was also lawful.
In The TVA Cases: A Quarter Century Later by George D. Haimbaugh Jr (Indiana Law Journal: Vol. 41 : Issue 2 , Article 2. Available at: https://www.repository.law.indiana.edu/ilj/vol41/iss2/2) Haimbaugh writes on page 200 of Tennessee Electric Power Company v. TVA.:
Again avoiding the broad constitutional issue, the United States Supreme Court, dividing five to two, affirmed the dismissal on the ground
that the complainants had no right to be free from competition and therefore had no standing to maintain the suit
On page 201 Haimbaugh writes:
The pith of the TVA cases was a challenge to the national government's constitutional power to compete with private enterprise. The Supreme Court which had not faced that problem directly before did not
answer it in those cases. It avoided passing on the validity of the valley-wide competition in which Congress had authorized the TVA to engage by denying the utilities' standing to sue.
The TVA cases offer, in Brandeis' concurrence in Ashwander, the best known formulation of the proposition that
The Court has developed, for its own governance in the cases confessedly within its jurisdiction, a series of rules under which it has avoided passing upon a large part of all the constitutional questions pressed upon it for deci3ion."' {297 U.S. 288, 341, 346 (concurring opinion)}
So, it may be argued that the decisions in Alabama Power and Tennessee Electric which turned on lack of standing were not constitutional determinations but instances of judicial discretion. The more widespread view, however, would seem to be that Tennessee Electric Power, at least, has amounted to a constitutional development and perhaps was a case in which the Court, to paraphrase Mr. Justice Jackson, should have tried to lay inevitable constitutional controversies to early rest.{Jackson, THE STRUGLE FOR JUDICIAL SUPREMACY 305-06 (1941)}
On page 202 lists as among the doctrines established by these cases:
The decision in Tennessee Electric goes even further than that in Alabama Power and decides that the non-exclusive franchise offers no protection against direct federal competition which is illegal only because it violates the Federal Constitution. {52 Harv. Law Rev. 686 (1939)}
On page 204 Haimbaugh writes further
The Supreme Court's refusal to grant standing to the complainants in Alabama Power and Tennessee Electric left unanswered the question of competition by the Federal Government beyond that in which it was
engaged at Wilson Dam. The Court in Ashwander had found the production of electricity to be a necessary incident to the making of munitions of war or the operation of works for navigation purposes, and the
sale of such power to be a reasonable disposition of the property thus come by. The Ashwander opinion suggests that a determination of the validity of federal competition with private utilities as presented in the later TVA cases would have entailed definitions of (1) the relationship of such activity to the exercise by the Federal Government of enumerated powers, and (2) the scope of its property power.