It is acknowledged that nitrosamines cause cancer. It is acknowledged that ranitidine breaks down on the shelf to nitrosamines: this wasn't discovered by the FDA or another government agency, it was discovered by a mail-order, compounding pharmacy which also tests ingredients. Their discovery led to ranitidine being recalled.
As for prilosec: the cancer risk is acknowledged in the packaging.