You're correct that it's a mistake to think that praying is aimed at getting God to do something he wouldn't otherwise do.
But praying does good, mostly for the person who prays. A Christian asking God for something is a lot like a lawyer, presenting a case in court: the process of preparing to make the case helps us understand what the right outcome should be, so we can recognize it when it comes. A lot of answers to problems wouldn't be recognized if we weren't ready for them.
Or picture ourselves aboard a boat. There are hawsers joining it to some rock. We take hold of them and pull on them, and it is as if we were dragging the rock to us when in fact we are hauling ourselves and our boat toward that rock. And, from another point of view, when someone on the boat pushes away the rock which is on the shore he will have no effect on the rock, which stands immovable, but will make a space between it and himself, and the more he pushes the greater will be the space.
That is why we must begin with a prayer before everything we do, but especially when we are about to talk of God. We will not pull down to ourselves that power which is both everywhere and yet nowhere, but by divine reminders and invocations we may commend ourselves to it and be joined to it.
-- pseudo-Dionysius (fifth-century mystic), the "Divine Names"; translated by Colm Luibheid
The miracles of Christ are accidental, however efficient; the kingdom of heaven fulfils all earthly laws because that is its nature but it is concerned only with its own, and to try to use it for earth is to lose heaven and gain nothing for earth. It may be taken by violence but it cannot be compelled by violence; its Incarnation commanded that he should be awaited everywhere but his effectiveness demanded nowhere. Everything must be made ready and then he will do what he likes. This maxim, which is the condition of all prayer, has involved the Church in a metaphysic of prayer equivalent to “Heads, I win; tails, you lose.”
-- Charles Williams, "He Came Down from Heaven"