Why did the children of Israel run out of food in the wilderness, causing them to complain? In the wilderness, the children of Israel on more than one occasion ran out of food and/or water to the point that they complained about it to Moses.

They probably had no way to get food or water on their, depending on the land.  They were completely dependent on God to provide for them.

When they ran out, they would complain to Moses.

Why did it go that far?  Why didn't God provide for them, or why didn't Moses ask God to provide for them, before they ran out?

God and Moses seem to be upset that they are complaining about the food.  Should they have asked for food/water?  Or should they have continued to wait without any food/water for it to be provided?

Presumably, Moses drank the same water they did, so he would also be in the same situation of having nothing to drink.
There are several passages that suggest an answer; in particular Deuteronomy 8:2–3:


  2 And you shall remember the whole way that the Lord your God has led you these forty years in the wilderness, that he might humble you, testing you to know what was in your heart, whether you would keep his commandments or not. 3 And he humbled you and let you hunger and fed you with manna, which you did not know, nor did your fathers know, that he might make you know that man does not live by bread alone, but man lives by every word that comes from the mouth of the Lord. [ESV]


This passage reveals two things: first, that God's overall purpose for the wandering in the wilderness was to test the Israelites and humble them, for their own good (cf. Deut. 8:16).  And second, that through hunger specifically they would learn that "man lives by every word that comes from the mouth of the Lord." (cf. Matt. 4:4)

This makes sense given the attitude of the Israelites recorded in Exodus 17 as they have just been fed with manna and now want water.  Despite being led out of Egypt and through the Red Sea, they doubted God:


  And he called the name of the place Massah and Meribah, because of the quarreling of the people of Israel, and because they tested the Lord by saying, “Is the Lord among us or not?” (Ex. 17:7, ESV)


So, based on these passages, we could conclude that God allowed Israel to undergo these trials to promote their spiritual development and teach them to rely on God.  They repeatedly failed these tests: instead of trusting God's provision, the Israelites complained and doubted God.