AT&T's liberal policies regarding software (and computer hardware) weren't out of the goodness of its cold blue corporate heart, but one episode out of over a century of antitrust enforcement against the original Bell System and its subsequent incarnations.
Most specifically, the 1956 consent decree arrived at by the US Department of Justice. In part:
The consent decree contained two main remedies. The Bell System was obligated
to license all its existing patents royalty-free, and it was barred from entering any
industry other than telecommunications. As a consequence, 7,820 patents, or 1.3 per-
cent of all unexpired US patents, in a wide range of fields became freely available in
1956."
<https://www.aeaweb.org/articles?id=10.1257/pol.20190086>
<https://pubs.aeaweb.org/doi/pdfplus/10.1257/pol.20190086> (PDF)
My understanding is that the decree also specifically* prohibited AT&T from engaging in either computer hardware or software markets. Consequence is that when AT&T developed operating systems, compilers, and associated software for the UNIX System beginning in 1969, it literally had no option but to give the fruits away gratis, or hold them internally.
That restriction was lifted after the 1984 anti-trust settlement, though it took AT&T a few years to start acting on that. Once it did the result was the "Unix Wars" of the late 1980s / early 1990s, which amongst other effects put a strong damper on commercial viability of BSD-based Unix systems, whilst an alternative coded-from-scratch run-alike system originating out of Finland faced no such headwinds. That system was Linux.
(This history is ... referenced in numerous sources, though I'm finding it difficult to turn up specifics. The 1956 DoJ settlement doesn't seem to be online at all, and this isn't the first time I've searched for it. Wikipedia discusses various elements of the AT&T antitrust actions, dating to 1913, but is fairly poorly sourced, see: <https://en.wikipedia.org/wiki/Bell_System#Kingsbury_Commitme...>. I'm pretty sure that the Unix / Linux history is covered in various sources, possibly some of ESR's writings or elsewhere. I'm pretty confident of my facts here, but would prefer being able to source my statements more concretely.)