Because a forest that has shrunk and dried can no longer feed and water the elephants living in it, so they walk out to where food is.
The chapter sets the events out as a chain:
Trees cut for roads and buildings → forests dry and shrink
Waterholes dry up → loss of habitat
Animals move into human habitats → crop damage, and at times harm to people and domestic animals
An elephant is a very large herbivore, so it needs a very large amount of fodder and water every single day. A farm or plantation offers exactly what a thinning forest no longer does — bananas and sugarcane standing close together, easy to reach. So the elephants are not straying at random; they are following the food.