Former officials and sources say that former President Trump’s “chaotic exit” from office and often careless handling of government records may have helped set the stage for the search.