- τoν is the definite article ("the") in the accusative masculine singular form
- Θεoν is the Greek word for God (θεός), in the accusative masculine singular form
- Θεοῦ is the same Greek word for God (θεός), in the genitive masculine singular form
In Matthew 5:8, the word "God" is in the accusative form because God is the direct object of the verb ὁράω -- He is being seen.
In Matthew 5:9, the word "God" is in the genitive form to indicate possession: the "sons" are the sons of God.
τoν Θεoν, whether in Matthew 5:8 or John 1:1, can be literally translated "the God"; the definite article indicates that it is a specific entity (this God) being referred to, not any god (The definite article has other functions in Greek as well, e.g. changing the subject/actor in a sentence). A noun without the definite article could be translated with or without an indefinite article ("a", "an"), depending on context.
But τoν Θεoν could be used to refer to Zeus, or Poseidon, or any deity. The Jewish context of Matthew & John is such that we know that's not the deity they are referring to, and "the Father" is a reasonable interpretative translation...but there's nothing in Greek that says the words "τoν Θεoν" can only refer to God the Father.
In Matthew 5:9 the genitive construction υἱοι Θεοῦ ("sons of God") does not require an article. It is also clear from context that the God Jesus refers to is the God the Jews believe in.