I don't understand how a culture from the other side of the globe had the same concepts from the west/middle east having the hell as a place of punishment
Okay, answering this question "in detail" is actually...nigh-impossible:
The Japanese concept of hell or purgatory (sanskr.: naraka) originated in India and was introduced to Japan via Buddhism. That's really it.
Apart from hell, many other ideas, such as various types of deities, demons and other, often malevolent, entities that can be found in the Japanese imagination, also originate in Buddhist mythology (and, by extension, the Hinduist ideas that Buddhism incorporated): for example, yakṣa (jp.: yasha) and preta (jp.: gaki).
Now, there are, of course, indigenous concepts of a netherworld beyond our own all over the place in Japanese folklore and mythology, although not as a place of punishment or purification.
The most well-known is the idea of the underworld as the place where the dead dwell (a widespread idea in cultures all over the globe). This kind of underworld appears as Yomi no kuni in our oldest written sources (e.g., the Kojiki).
There are also various other allusions to different worlds in local folklore (there was no unified, singular mythology shared by everyone in premodern Japan, but rather countless local beliefs).
For example, mountains were often worshipped as a sacred place. Some local faiths imagined that there was a "place" far beyond the mountaintop where the spirits of the dead departed to. This common view of mountains as sacred places, or places between the worlds, is likely related to the mountain being often the training place of yamabushi, adepts of Shugendō. Furthermore, this kind of belief might be somewhat related to how it was common in premodern local society to bury the dead by leaving them out in the open at a burial ground, which often was located in the forests at a mountain's base (to be fair, this kind of burial was also simply the cheapest option available).
Similarly, especially in Kyushu and in maritime communities around the Seto Inland Sea, you can find the idea that the spirits of the death would depart to some place beyond the ocean (incidentally, Okinawan folklore—another ocean-centered culture—possesses a similar idea in Niraikanai). As an example of this, in the Kojiki (yet again), you can find mention of Tokoyo no kuni as one of the places where gods reside. Such a place beyond the ocean is often perceived as a paradise of sorts in folklore, where time flows differently. For this property this kind of idea often appears in stories pertaining immortality or eternal youth.
In sum: there are many ideas and attitudes towards worlds beyond our own, which can be found in various forms in the oldest written sources and onward, whereas the concept of—Buddhist—"hell" specifically has been introduced to Japan via Buddhism (duh).
Now, of course, one could ask to what extent the Buddhist concept of hell, and the afterlife, is similar to other comparable concepts (such as Christian mythology), but that is a question I'd reserve for a scholar of comparative religions.