I can assume that the hands used to be the same as legs. And they got weaken, and changed direction when human started to walk on two? Also why do the hand palms facing the body and not facing down like the feet?
I am no expert on comparative anatomy, but I will give this a shot. Please edit if you know more about this subject!
The configuration of opposing elbow and knee joints is a feature we humans share with large group of mammals. For example, below is an image of a shrew skeleton.
Opposing joints are course a major feature of mammalian anatomy, and there are many studies on its functions and advantages. Among other things, this configuration allows for characteristic gaits of mammals such as the gallop of a horse, and it allows mammals to rest with legs protected under their body. See this page for some basic information.
Neil Shubin's book Your Inner Fish on human evolution also discusses the opposing joints arrangement, noting that this is a "key feature that gives us the capacity to walk, one we share with other mammals". A preview of the book is here.
A quick literature search turns up many technical articles on this subject, such as this review series. I'm afraid the details are beyond me (again, experts please edit), but I think it's fair to say that there is plenty of evidence for advantages of this joint arrangement in mammals.
Unfortunately, your question isn't clear. "Why" could mean different things. What course of events led to it? What benefits does it provide? We could just say, it's not disadvantageous this way, so why not. So perhaps you could clarify.
Evolutionarily, through the stages as our ancestors evolved from small mammal to human, the changes that occurred were sufficiently suitable for the species. The joints are oriented well enough for walking, running, and holding things, and there doesn't need to be more reason. As for the hands, they point away from the arms like they do in other great apes. The difference is that in humans, the feet have a hard time pointing down since they are never used as hands, and hands have a harder time pivoting to be perpendicular to the arm because they are never used as feet anymore. Because of these behavioral differences from other great apes, variations that helped feet be used as hands and hands be used as feet were not selected for, but variations that reinforced walking and running ability and that reinforced object manipulation were selected for.
It's an amazing question, really. And you might be right about your assumption. In the womb, our legs and arms bent in the same direction. But as the foetus continued to develop, the legs and arms rotated to bend in opposite direction (to each other). As of now, there is no rational explanation as to why this happens.
So I guess all we can do is be grateful to the way our bodies have come into being. If, for instance, our knees bent backward (just like our elbows), our legs would bend forward like our arms and we wouldn't be able to walk the way we do. Apply the same to the arms and we'd be lifting things in an entirely different way, and backwards too! Also, we won't be possessing the ability to write.
You can check out this page for more info:https://answersingenesis.org/human-body/your-legs-are-on-backwards/