The US government does issue life insurance for all military personnel. It's a nominal cost (20 bucks a month IIRC) for something like 400k of coverage. It's been around since 1914[1].
As far as I know all of the astronauts were military at that time, so they probably would have been covered by this program. There could be any number of nuances I'm not aware of though.
[1]https://benefits.va.gov/benefits/infographics/pdfs/timeline_...