Only a few betray their country. Many betray the companies they work for. Corporate loyalties are thin these days. High worker mobility in high-tech industries and corporate restructuring that lays off longtime workers have frayed the threads of loyalty. This would not seem to apply to the FBI or the CIA, but traitors there are rare.
Most spies go undiscovered for many years.
It takes overt acts, foolish mistakes or a tip provided by a friendly competitor or another spy to make the connection. This suggests that a lot of espionage goes undiscovered. Revelations cause shock and prompt inquiries. Reviews will reveal embarrassing security lapses. Wherever there are procedures, there inevitably will be violations of procedures.