Palantir has become one of the few winners in the Trump administration’s cost-cutting efforts, offering other contractors a lifeline while consolidating its own reach and power.