In the books, Denethor has the beacons lit before Gandalf even gets to Minas Tirith. On their ride there, he and Pippin see the beacons going up, and Gandalf remarks that that's a sign that they are short on time.
As for the movie... some have said that Gandalf is forbidden from using his powers to directly influence events in Middle Earth. He's supposed to be more of an advisor who helps the people of Middle Earth work to solve their own problems.
I think the real reason is that PJ wrote it in since it's more dramatic.