But the SHARE IT act really helps formalize what was already happening. Most code is shared and made public. It's paid for by the public. Though it's usually not easily searchable as it's distributed via different platforms, means, and may even require submitting a freedom of information request first. But in more cases than not, there is obligation to share when requested.
https://www.congress.gov/bill/118th-congress/house-bill/9566