If one of the two nouns has the article, it is the subject. In this case, “Word” has the article, even though it comes after “God,” and hence is our subject. That is why the last phrase is translated “the Word was God” rather than “God was the Word.”