Terraforming is the process of transforming a celestial body to become habitable by Earth-like life.
Even when I try to imagine an advanced civilization, the cost, time and complexity to terraform a planet seems like a real challenge. Terraforming Mars seems like an easy job compared to other planets and yet it would be a daunting task:
Mars's mass is much smaller than Earth's and it has no magnetic field. This means that there is nothing to stop the ultraviolet radiation and only a thin atmosphere. Less gravity makes it harder to have a thicker atmosphere.
Mars is cold, we would need to make it warmer possibly using the greenhouse effect but for this we need to add tons of gases on the planet. We would to take the gases form Earth or directly from Mars. Considering the quantity we produce on Earth and that it's only starting to warm up the climate, it would take a lot more to get Mars to have the same temperature as Earth. And it would take a lot of time. At least a century, because we have to warm it and make sure it stabilizes at the end.
And I will stop there because it is not really the point of the question.
I make the assumption that terraforming is really complicated. But I admit that maybe, in a distant future, (or in a distant science fiction future) advanced civilizations might have enough wealth and technology to consider terraforming a planet. The problem is that, with advanced space travel, they might be better to search for another planet, it would be much simpler in my point of view.
Terraforming could be a solution for us since we have problems on Earth but it's not feasible right now. By the time it will becomes possible to do such wonders, space travel will be a better option. Finding a planet with less challenges might be easier.
So, I'm trying to understand why in a lot of science fiction stories and games, civilizations would favor terraforming a planet instead of looking elsewhere.