As it mentions in Logan (2017), Caliban was a tracker for the evil company to eliminate mutants. He is a bad guy too in X-Men Apocalypse. But why did he become a good guy helping Logan and Charles? Is there an explanation for this?
First, the Caliban of Apocalypse and Logan were accidentally casted. Logan's director didn't know Caliban was already used in Apocalypse.
Second, Caliban in Apocalypse wasn't a bad guy. Just a black market information broker. He used his power for money, self interest. Nothing outright evil, just not a hero.
In Logan's back story, Caliban was a morally ambiguous paid tracker of mutants. He was told the mutants he was tracking were dangerous and needed to be stopped. Eventually he caught on that they weren't and since the mutant population had dropped off he was no longer needed. He was tossed aside like a stray dog. As he said, his mutant power became useless when there were no more mutants to chase.
He has a change of character over the decade because he had no purpose. He doesn't really become a good guy until the events of the movie. Logan had hired Caliban to make sure Xavier was far enough away and hidden from any mutants who could harm him (Or be harmed by him), while making sure Xavier doesn't get lost. He becomes a good guy when his decades long resentment over what he did before, betraying mutants for money as Logan puts it, gets brought up by being forced to track Logan at gunpoint. Being confronted by the Reavers and knowing that they would kill him this time once his usefulness was over, he fights back. He's not so much good as he is an anto-hero, like Logan.
Why the story does this is because the whole movie is about second chances, about change in life. Logan changing from the selfish prick back into a hero, Xavier being given a chance for a real life on the Sun Seeker after being an essential prisoner in mind and body, Laura escaping her prison and being free, etc. Caliban was also given the chance to correct his prior bad deeds.