Parshas Chukat contains the short episode describing the attack by Amalek on Bnei Yisrael. The Amaleikim disguised themselves as a Canaani tribe by speaking in the Canaani language, hoping to cause Bnei Yisrael to pray to be saved from the wrong attacker (interesting parenthetical point: you see that even Amalek accepted the notion that through prayer Bnei Yisrael would win, otherwise the whole rouse is meaningless). Bnei Yisrael were not completely thrown off - Amalek changed their speech but not their mode of dress, so Bnei Yisrael suspected that Canaani speaking people may not be who they appear to be. Instead of davening to be spared from a specific attacker, be it Canaani or Amaleiki, Bnei Yisrael davened stam (Rashi 21:1) and their prayers were answered.
Had Bnei Yisrael davened to be saved from Canaanim instead of Amaleikim, the implication is that their prayers would not have been efficacious. Wouldn’t Hashem “realize” that their desire is to be saved no matter who the attacker is and respond to that plea even if the specifics are off? Apparently not! The gemara (Bava Metziya 106) reflects this notion l’halacha. If one rents a field in New Orleans in exchange for paying the owner a certain number of bushels (chakirus), and agrees to plant wheat, if the entire city is flooded one is exempt fulfilling the terms of the rental agreement. However, if one plants barley instead of wheat, even if the entire city floods one is still liable for payment to the owner. Why is the renter liable just because he switched the terms of the agreement and planted barley - no matter what he/she planted, the crop would have been destroyed with the rest of the city?! The gemara explains that the owner has a right to say that he was davening specifically for wheat fields, and had the renter planted wheat instead of barley perhaps Hashem would have accepted his tefillah and spared the crop so he could collect the bushels owed. Tosfos (d”h nisa) writes that this halacha only applies if the owner specified the type of crop to be planted. However, if the owner said plant what you like and I will take a percentage, then we do not assume that his general tefillah for hatzlacha will be answered and his crops spared.
The mitzvos each are a precise formula and do not tolerate deviation. No one would say that if you have the right intention when you bake a cake, even if you put in the wrong ingredients and bake it at the wrong temperature, the finished product should come out OK. Our episode underscores the point that the words themselves are at least as crucial as the accompanying intentions.