WASHINGTON—President Donald Trump’s public complaints about the sweeping spending bill he threatened to veto before signing it into law Friday highlighted his discomfort with the classic Washington compromise: nobody wins everything, but both sides get some of what they want.

The bill that will fund the government until October gave neither party what they wanted on immigration policy. But by boosting spending by more than $140 billion above limits set in 2011, lawmakers from both parties got enough policy wins to live with...