While your GIGO observation is true, here is how it works.
I'll use Google Gemini for example because I know it best.
Google has partnered with libraries, universities, museums and cultural/governmental institutions for their data.
So if you ask a question about George Washington, NO you're not going to find info posted by some rando on Reddit.
Sources for Gemini include:
Digital Public Library of America
Europeana
HathiTrust Digital Library
Internet Archive
Library of Congress
Project Guttenberg
Smithsonian Libraries and Archives
New York Public Library Digital Collections.
And Google works with smaller groups like the Archive of the Egyptian Museum Cairo (AEMC) for everything they have including 50,000 photos, manuscripts and plans.
Google uses filters and ranking systems to judge quality of sources so don't worry about gigo, particularly with established topics like mathematics, engineering, history and philosophy.
AI sometimes tends to have difficulty with current events, pop culture and such things