Because they are very disorganized in their lives and don't know how to prioritize and don't realize people who are organized and know how to make priorities consider last-minute acceptances to be inconsiderate. IMO - Rather than stop inviting them, call them on it, nicely, of course. They may not have even thought that you need to plan for an appropriate amount of food, for example, and may not have enough for everyone if they don't let you know in advance. Ask them to give you at least 'x' days notice for future events, or plan not to come. Let them know you enjoy their company and want them to be there, but that having to rush out and buy more food at the last minute interrupts your preparations and causes you stress. That's not really too much to ask.
Was that answer waaaay to long?
PS - And once you've had that convo, it is important to stick to your guns. The first couple of times they call at the last minute and you tell them "I'm sorry, but I did ask you to give more notice than this, and I have already finished my shopping and won't have enough food if you come. I'd love you to come to the next get-together, though." will be awkward, but will let them know you are serious - and will prompt them to start giving more notice if they value your friendship.