The answer must be because ocelots are part of the biome that exists in the rainforests of Central and South America. A ‘biome’ is a community of animals and plants living in a certain place and they are linked or associated as predator and prey with respect to animals. The animals and plants are adapted to the environment.
That said we should be clear that ocelots are not exclusively forest and/or tree dwellers. They are…
“found from sea level to elevations of about 1,200 meters in a broad range of tropical and subtropical habitats, including tropical evergreen forest, semideciduous forest, dry thorn forest, mangrove and seasonally flooded savannah….They are highly dependent on dense cover.”
The rainforest is one habitat where the ocelot is found. However, the “ocelot is fairly specialized; it has become adapted to living in areas of dense cover with high rodent densities”.
Because the ocelot has evolved within a biome where there are a lot of trees they are agile climbers and leapers. They escape to trees when hunted. However, they are not arboreal cats (tree dwellers) in the true sense.
To recap: ocelots live in the rainforest of Central and South America because they have evolved within that environment with countless other animals some of whom are prey for the ocelot and others might prey on the ocelot (although the top predator, the jaguar, does not it seems prey on ocelots). The plants and trees of that habitat provide a home for ocelot prey. It’s a stable, balanced and harmonious community of plant and animal life providing for the ocelot’s survival.
Associated: Ocelot sounds. The quotes are from Wild Cats of the World by the Sunquists (great book).