I agree that it should've stayed, but maybe it felt that with it's mission completed it could stay with it's kind, however if it came to miss Ash, then that would be reason enough to want to return.
It's better reasoning than how your behaving about it.
it's not good writing, Ash has had late captures before, but never this late, the league is coming and Ash still needs one more pokemon (unless they want to pull reserves out, or not give us any full battles) Poipole from a logical standpoint is the only pokemon they could give him that wouldn't feel rushed because it has had character development with Ash, which is just as important as being able to fight.
Meltan on the flip side might be battle capable, but it is still going to need more focus on it's character, and having Ash catch something random is only going to make things worse for the team, because they may not be done with the others development.
on top of that, the writers are giving his classmates a lot of focus too that detracts from Ash and his team, and in some cases not in good ways, take the next episode for example, interesting fan service maybe, but how does this help them grow as characters?
Meltan might be better at battling than Poipole, but beating up team rocket is not a good indicator of one's power because they generally lose all the time as it is.
A really good pokemon is one that has both good battling skills and good character development, having too much of one and not both causes it to fail.