Government networks are attacked nearly every day, but the intruders are rarely successful. The breaches in March were significant enough that F.B.I. agents in Washington have opened an investigation into the attacks, which the agents say they believe are connected.

James A. Lewis, a cybersecurity expert at the Center for Strategic and International Studies, said that it made sense for foreign hackers to target the networks of the accountability office and the personnel office, but that the printing office was curious.

“G.A.O. looks at military, intelligence and economic programs, and you would want to see the information they have that hasn’t been made public, like their notes,” he said. “O.P.M. has all the information on security clearances, and who is applying for them.”

“But was G.P.O. a mistake?” Mr. Lewis said. “Is it just them not understanding how things work or not understanding what it stands for? They could have found a way in, and these were the agencies that came up. This is some guy sitting in an office in China who doesn’t have a sophisticated understanding of how the U.S. government works and doesn’t have a lot of direction.”

The attacks occurred at a time when cybersecurity disputes between the United States and China have grown more contentious, with each side accusing the other of unethical, if not criminal, behavior.

In May, the Justice Department unsealed an indictment that charged five hackers who worked for the People’s Liberation Army with stealing corporate secrets, in an attempt to deter the Chinese from attacks on American corporations.

The Chinese have countered by saying that the Obama administration was hypocritical. Citing disclosures from Edward J. Snowden, the former National Security Agency contractor, China said the N.S.A. had gone deep into the computer systems of Huawei, a Chinese company that makes computer network equipment, and had spied on Chinese military and political leaders.