Most kanji are borrowed directly from Chinese, without really being changed, and most Chinese hanzi are composed of two main parts: a semantic part and a phonetic part.
The semantic part doesn’t have to give the complete meaning, but usually is something “kind of relevant”, although I often find the semantic part to be quite far-fetched.
The phonetic part usually once was phonetic, but since pronunciation changes over time and is influenced by dialects, or in case of Japanese a completely different language, this isn’t a strict rule either. It’s a bit like pronunciation in English, where the spelling has some use to finding the pronunciation of a word, but quite often has diverged a bit and seems unrelated now (consider enough, though, ought, borough, where ough is quite different).
For 圍, the semantic part is 囗, which means “enclosure” in this context, and the phonetic part is 韋, which is pronounced as wéi in Mandarin. Other hanzi that also contain 韋 as their phonetic part are also pronounced wéi in Mandarin, for example 違 or 湋.
Similarly, the Chinese character for Go is 棋, which is composed of the semantic 木 and the phonetic 其. 木 means wood, referring to the wooden board that strategic games like Go and Xianqi (Chinese chess, which also uses the character 棋) are played on. The pronunciation of 其 is qí in Mandarin.
Both in Japan and in China, several reforms have led to simplification of the characters in different directions. The pronunciation has also shifted over time.
In simplified Chinese 圍 has become 围, using the phonetic part 韦, while in Japan it became 囲, using the phonetic part 井. Japanese lacks a we or wi sound, thus this kanji is pronounced i instead.
As for 棋, there exist many historical variants of this character, where the semantic part has been changed, or the location has been changed, like 檱, 棊 or 䃆. It happens that in Japanese 棋 has the more general meaning of “strategic board game” (and is used for Shogi, or Japanese chess), while 碁 has become the standard for Go. The pronunciation of both 棋 and 碁 is borrowed not from Mandarin, but from Cantonese, and has become ki, gi or go in Japanese.
There’s another complication in Japanese, which is that most kanji have several different pronunciations. This is because kanji often borrow one or several Chinese pronunciations (since it may have been borrowed from several different dialects) as well as one or several Japanese pronunciations. For example, 囲む is pronounced kakomu, which is the original Japanese pronunciation of the word meaning “to surround”. Of course this has nothing to do with the phonetic part of the kanji, since the phonetics don’t relate to Chinese.