A clearer example, I think, is birth rates. Everyone agrees that a low birth rate is a major economic challenge for European countries and Japan. Everyone agrees that the basic problem caused by a low birth rate is too many old people and not enough young workers. Immigration is functionally the same as increasing birth rates. In fact, it’s the main alternative to increasing birth rates: Your two choices for getting more people are making them or importing them. And yet, many of the same people who think it’s important for America to make more people are steadfastly against America importing more people.
But in the (incorrect) model where the economy contains a fixed number of jobs, immigration is arguably preferable to increasing birth rates. Immigrants tend to have different skills than native-born workers. Native-born workers, conversely, have, by definition, the same skills as native-born workers. So more native-born workers means more competition for the fixed number of jobs. More immigrants means that classes of jobs that might otherwise go unfilled because they don’t match up with the skills of native-born workers instead get filled. See this article for some examples.
In the real world, of course, the supply of jobs isn’t fixed. It’s dependent on the growth of the economy. And here, the economic evidence is clear: Immigration, in the aggregate, increases growth and, in the long-run, jobs.