First off, your premise is not necessarily correct; for example, the Chicago Blackhawks' top minor-league affiliate is the Rockford Icehogs, located a short distance away in Rockford, IL, well under an hour's plane ride. San Jose and Winnipeg have that beat though: they share an arena with their affiliate!
You're not wrong that being near would be helpful to some extent. What you'll find I think is that the AHL teams are not entirely fungible - some have better management, for example, and some locations are in very under-served markets and so have very large fan bases. The AHL team is still a business, and in some ways more of a business than the NHL team (as it's much lower margins), and so there is a place for well run AHL teams even if they're not close to an NHL team. And airplane travel is not difficult (outside of COVID, anyway), and not particularly expensive on NHL budgets, so it's not a huge deal to have a team further away; they're not flying multiple players every day, or anything like that. And the teams themselves are flying regularly anyway - half the time, your callup needs to fly somewhere regardless of where your AHL team is, if it's an emergency callup and not a planned one.
This USA Today article talks about how some NHL teams are moving their AHL affiliations closer, in part for the reason you mention (calling up players more easily), but also to let the executives see games with the AHL players more easily.