You've noticed, I expect, all the other strange language features, like the unusual verb form "saith" instead of "says", the odd word order as in "thus have they" and the strange vocubulary such as "iniquity".
I expect you're reading from the Authorised Version (also known as the King James Version), a translation made in the 17th century and written in a style which as a little old-fashioned even in those days.
Languages always change over time. Grammar changes, words go in and out of fashion, and many words even change their meanings, add new meanings or lose old meanings.
Such is the case with "visit". It comes from a Latin word meaning "to go in order to see", a meaning very similar to the usual modern meaning. Soon people used it in the context of sickness and disaster, which would "visit" the population, an unwelcome and unpopular visitor. From there it's just a short step to using the verb to mean "cause to visit", "to send an unwelcome visitor (e.g. plague)", thus "to inflict" or "to punish".
This particular usage is now obsolete -- we don't say that God visits sins, we say he punishes sins, except perhaps in some of the more old-fashioned churches. However, we do sometimes still use "visit" to describe disaster of some sort afflicting the population; for example, the Great Plague visited London in 1665.
Student or Learner