If two species overlap in their habitat use, how can both persist?
Because they don't overlap entirely in their use of the habitat.
If two animals overlapped completely in their habitat usage and diet, eventually one species of animal would outcompete the other, causing the less successful species to go extinct. However, usually there is not complete overlap.
Most animals share the habitat with multiple other species, and some of those species will likely eat the same things. One species may consume nectar from a flower in the habitat at night and the other consumes the nectar during dawn and dusk only. Or one species primary eats a certain type of grass, whereas other species in the habitat only consume that grass as a last resort.
Let's take for example Cooper's hawks and Broad-winged hawks which both consume mice and live in forests. They share the same habitat and the same food, but their overlap in diet and habitat usage is not exact. Broad-winged hawks grab their prey from the forest floor, eating small rodents, frogs, toads, and even nesting birds. Cooper's hawks on the other hand mainly consume birds such as robins, pigeons, and doves but they will also eat mice, chipmunks, and squirrels on occasion.
So, while both birds prey on mice, they also prey on many other species and exploit and use their habitats differently.