This is mythology. It is part of the understanding of Job and the people of his time about how the affairs of mankind were affected by the gods. We see this mythology fleshed out more fully in other civilizations such as the Greeks and Romans.