Another verse that supports this concept:
Mark 11:24 (NASB)
Therefore I say to you, all things for which you pray and ask, believe that you have received them, and they will be granted you.
Why doesn't this work?
Let's look at things a bit more in context (of Mark):
Mark 11:22-24 (NASB)
22 And Jesus answered saying to them, “Have faith in God. 23 Truly I say to you, whoever says to this mountain, ‘Be taken up and cast into the sea,’ and does not doubt in his heart, but believes that what he says is going to happen, it will be granted him. 24 Therefore I say to you, all things for which you pray and ask, believe that you have received them, and they will be granted you.
It's very clear that God will answer any prayer you have. However, if you don't have faith, your prayers won't be answered.
Furthermore, we should pray continuously for something we want! We see this in the parable of the widow and the unjust judge. The widow constantly bothers the judge and he finally relents even though he is neither godly nor just. He basically says "Fine, you can have it, go away."
Finally, we need to make sure that we're asking for the right motives. James 4:1-3 shows that if we're asking for things for our own earthly pleasure, then that's the wrong motive. Like Jesus, we should try to keep God's will in mind when we pray for something.
So, why doesn't it always work to pray for something?
Here seem to be the biblical criteria:
- You must have more than one person agreeing on the need
- You must believe that it will be granted
- You must pray continually about it and make your prayers constant until it is granted
- You must ask with the right motives
Then, you will be able to move mountains.
A word study
This isn't really necessary for the answer (once I re-read the question), but I'd already written it up, so I'll include it here:
This gets a bit more interesting in the Greek.
Again, [I-am-saying] [to-you] that [if-ever] two [of you] [should-be-agreeing] on the earth concerning [any/every] [practice/matter] which [if-ever] [theys-shoud-be-requesting] [it-shall-be-becoming] [to-them] beside the father [of-me] [the-one] in heavens
The translation in question "anything" actually comes from two words: pantos [any/every] and pragmatos [practice/matter].
The word pantos is pretty self-explanatory, if you simply accept that it means "each thing, all, or every". The word pragmatos is a bit more interesting, though:
Vines lexicon shows:
From the root pragma (Strong / Vines entry)
1. that which has been done, a deed, an accomplished fact
2. what is done or being accomplished
a. spec. business, a commercial transaction
3. a matter, question, affair
So, in essence, the verse is saying that if ever two of you agree on the earth about any practice, every deed, any question that they are requesting, it will be given.
Word definition summary
Essentially, if two or more people agree to ask for any deed to be done or any question to be answered, God will do it.