Expanding a little more on the rationalist approach in other answers (sorry, I can't recall any sources for this):
We each have a relationship with Hashem. We know that Hashem is immutable - He cannot change. Therefore, if our relationship with Him changes, it must be a change on our part, not on His.
To put it another way, Hashem always does what is Good. What is Good for me will change depending on my behaviour. In order to correct my course in life, it is sometimes necessary for me to be punished. I think of it like the cars which have a system that beeps loudly to warn you if you drift out of your lane on the road. The punishment is like the beep to remind you to get back in lane. If we don't drift out of the lane, we don't need that warning, that nudge to remind us what direction we're supposed to be heading in.
At times, I think a sat nav might be a better analogy. I'm sure we've all had times when we've set the sat nav and then changed our mind towards the end of the journey exactly where we're going, and it keeps trying to correct us, not knowing that we've changed our destination. This is the other way around - the sat nav is right, and we're wrong. Sometimes I think it feels like we're fighting battles because we don't realise that we're heading in the wrong direction and so we keep getting more and more nudges to push us back on path.
The reverse can be true as well though. Sometimes things just flow incredibly easily and life goes well. At times, maybe that is because Hashem is rewarding us for following the correct path - the one which leads us to self improvement and becoming a better person.
The above is somewhat simplistic - it is also possible that difficult times and easy times are tests for us, so it could be for the opposite reason. Hashem knows what we need to get the most out of ourselves, but we need to do some introspection to try to work out what it means. In either case, self improvement is a good approach - that's our constant goal.
One more moshol to help. If someone had committed a brutal murder and there is plenty of evidence that they did, there are two scenarios as to how the jury could react. In one case, they may vote to give the maximum sentence (eg. death) because they feel that there is no hope of rehabilitation and this person is a danger to society and likely to repeat the offense. On the other hand, they may believe that this person is genuinely sorry, they have spent hours soul searching and done everything that they could to repent and change their ways. It won't bring back the victim, and the jury probably won't let them off, but the sentence is likely to be a lot lighter. In this case, the jury can't be totally certain that the person has fully repented, and of course they wouldn't want to set a precedent for other murderers to think they can get off scot free in future, but Hashem doesn't have those worries. If we've totally repented, our past behaviour is no longer relevant, because we're now a constructive member of society and don't need any correction anymore.
It is worth noting that it isn't just prayer that can change things. In the davening on Rosh Hashanah, we just said "teshuva, tefilla and tzedaka can change the decree". Anything that helps us improve ourselves works.
I think that the reason that we refer to Hashem as though He was a person, and we do things like begging for mercy is that it is much easier to relate to Hashem as though He was another human. After all, we no experience in relating to other beings who we can properly communicate with except other humans. We don't really have the ability to understand who Hashem is properly - He is infinite and we have only a finite ability to perceive and understand. If we tried to pray to Hashem as He actually is, we wouldn't have the capacity to do so, and it would feel very unnatural. We may have some limited intellectual ability to understand some of Hashem, but we can't rely on that abstract understanding - we need something that we can put into practice.
Also, I think that as we go through life and take on different roles, we get a different understanding of how Hashem treats us. As a child, we think of Hashem like our parents and how they treat us. As an employee, we get a different perspective on what it is like to work for someone, perhaps as part of a team to achieve something overall. As a boss, we may see the other side of it and gain a different understanding of that same relationship. As a spouse, we see things from yet another perspective, in a far more intimate way than anything else. As a parent, we see a different side of the parent-child relationship. I'm not there yet, but I'd imagine that the same is true as a grandparent. As each of these relationships develop, we learn new things. I'm British, and the death of Queen Elizabeth II has made me (and many other people) think a lot more about what it means to have a monarch and be a subject. It is fascinating to see how much she affected people's lives in ways that we weren't conscious of until she has gone. She never had the kind of power of the monarchs of earlier times, but she still had an incredible ability to bring people together and inspire them to work together for the greater good. With each of these relationships, we can apply each piece of our new understanding to enhance our relationship with Hashem, not because that is really the way it is, but because that's the best way that we can achieve some kind of limited understanding.