The other situation that I've seen this in is job ads posted by recruiters who post way-above market-rate salaries and then try to bait-and-switch you when you answer the ad. Also a big red flag.
Mostly, though, I am interested in negotiating, and don't want to commit to a number even before I've had a chance to make a favorable impression on the employer, because then they could say "well, you knew ahead of time what we were paying, so why are you trying to negotiate?" Well, if they had posted a realistic number or their best possible offer, maybe there'd be no need to negotiate -- but that is virtually never the case.
Employers know this, so they just adjust their advertised range downwards so that the "Y" in "X to Y" is actually at the low end of the range they're actually willing to pay.