here is, I believe, the latest guidance around this:
https://www.whitehouse.gov/wp-content/uploads/2017/11/Circular-097.pdf
and in it a quote from Section 302 of the Intergovernmental Cooperation Act of 1968, which still provides the foundation today:
"The Director's rules and regulations shall be consistent with, and in furtherance of, the Government's policy of relying on the private enterprise system to provide those services which are reasonably and expeditiously available through ordinary business channels."
there's legislation coming down the line to hopefully change this. aaron snow wrote a good blog post about this more in-depth as it relates to both the US and Canada here: https://aaronsnow.net/2022/05/09/sharing-federal-digital-services-with-other-layers-of-government.html. recommend checking it out if you're interested!