I was wondering, for example, when the Israelites were attacked or they attacked someone else, Moses held up his staff and it helped Joshua's army, but if the staff was held down then the war went for the enemy. Obviously the power of the staff came from God, so that means that God was letting the enemy die. Did He do this because the enemy was going against the Israelites (God's people)?
The event you are referring to only happened once.
"Now Amalek came and fought with Israel in Rephidim. And Moses said to Joshua, "Choose us some men and go out, fight with Amalek. Tomorrow I will stand on the top of the hill with the rod of God in my hand." So Joshua did as Moses said to him, and fought with Amalek. And Moses, Aaron, and Hur went up to the top of the hill. And so it was, when Moses held up his hand, that Israel prevailed; and when he let down his hand, Amalek prevailed. But Moses' hands became heavy; so they took a stone and put it under him, and he sat on it. And Aaron and Hur supported his hands, one on one side, and the other on the other side; and his hands were steady until the going down of the sun. So Joshua defeated Amalek and his people with the edge of the sword. Then the LORD said to Moses, "Write this for a memorial in the book and recount it in the hearing of Joshua, that I will utterly blot out the remembrance of Amalek from under heaven." And Moses built an altar and called its name, The-LORD-Is-My-Banner; for he said, "Because the LORD has sworn: the LORD will have war with Amalek from generation to generation"" (Exodus 17:8-16).
In this particular case, Israel was defending itself against a hostile attack by another nation. The reason the success in the battle was tied to Moses holding up his arm was God proving that it was He who was fighting the battle. After all, think about it, how can a battle be influenced by some guy holding up his arm? Moses and all of Israel realized that it wasn't their greatness that won the battle, but God's.
Because Amalek sought to destroy Israel, God stated that battles would continue until the nation was wiped out. "Remember what Amalek did to you on the way as you were coming out of Egypt, how he met you on the way and attacked your rear ranks, all the stragglers at your rear, when you were tired and weary; and he did not fear God. Therefore it shall be, when the LORD your God has given you rest from your enemies all around, in the land which the LORD your God is giving you to possess as an inheritance, that you will blot out the remembrance of Amalek from under heaven. You shall not forget" (Deuteronomy 25:17-19).
Notice that it wasn't because God was seeking to destroy people that this war occurred. You have a nation of bullies who thought they could take advantage of a travel weary people. They learned the hard way that God was protecting Israel. But God also sat in judgment on this nation and declared that such evil cannot continue and that He would remove this nation.