Wub has it right:
"My understanding is that it was revealed because they wanted to fly them during the day. Up till it was made public it had only been operated at night and as a result there had been losses."
There was also the fact that the USAF wanted to upgrade the 4450th TG to full TFW status, there was a need to retire the ancient A-7s that had been the 4450th's 'cover story', while the original Conops (of using the jet as a 'plausibly deniable' way of hitting the USA's enemies) had proved legally questionable and of dubious usefulness. Every time they'd got close to using the jet in anger (Beirut in '83, Tripoli in '86) Weinberger (or his legal advisors?) had been spooked into scrubbing the mission.
The B-2 was a whole different ball game - while the 117 had been developed in the 'black' world, the B-2 was a publicly acknowledged programme, openly funded, and revealed long before the successful Northrop design was selected over the Lockheed/Rockwell competitor.
What the -117As are doing today, still flying, really is an interesting question, though.