An examination by The New York Times, based on interviews with more than 30 current and former law enforcement, congressional and other government officials, found that while partisanship was not a factor in Mr. Comey’s approach to the two investigations, he handled them in starkly different ways. In the case of Mrs. Clinton, he rewrote the script, partly based on the F.B.I.’s expectation that she would win and fearing the bureau would be accused of helping her. In the case of Mr. Trump, he conducted the investigation by the book, with the F.B.I.’s traditional secrecy. Many of the officials discussed the investigations on the condition of anonymity because they were not authorized to speak to reporters.