President Trump has offered lavish praise when the intelligence community or law enforcement investigates his opponents but rebuked them when their actions do not align with his interests.