I suspect you're asking slightly the wrong question.
I think you really have in mind the distinction between restrictive and non-restrictive adjectival clauses.
The restrictive clause is the one that cannot be omitted if the object it is modifying is to be properly defined. For example, "There's the man who hit me yesterday".
The non-restrictive clause is the one that can be omitted. "There's my enemy, who hit me yesterday".
Conventionally the so-called rule has been that the restrictive clause should be introduced by the pronoun "that", and the non-restrictive clause by "which", "who", "whom".
As my two sentences show, however, the real distinction is that non-restrictive clauses involve a slight pause in speech, indicated by a comma or commas in writing.
Therefore if you mean a restrictive/non-restrictive distinction in your sentences (1) and (2), the comma is crucial.
(1) It was the blue window that [which] Seho broke yesterday. No comma, restrictive: As for the window Seho broke yesterday, it was that one out of many possible ones.
(2) It was the blue window, which Seho broke yesterday. Comma, non-restrictive: It was the blue window we've been talking about (that was the one Seho happened to break yesterday). [ "That" is no longer common in English to introduce non-restrictive clauses, but was frequent until the eighteenth or even nineteenth century. ]
In your sentences (3) and (4), the meaning is necessarily restrictive, and both sentences mean the same thing. As for the person who saw the accident yesterday, it was Tom -- out of many people.
Here, with comma, is a non-restrictictive version of the same sentence:
I saw a man standing at the corner. It was Tom, who saw the accident yesterday. "That" is no longer common here in modern English.
So, in response to your concern about what is grammatical: the non-restriction is indicated with pauses or commas, and needs a "who" or "which"; a non-restriction is indicated with the absence of a pause or a comma, and can use both "that" and "who/which".
By the way, appositive noun phrases are restrictive or non-restrictive without the relative pronoun, but are likewise signalled by the pause.
The philosopher Thales lived in Asia Minor. "Thales" restricts "philosopher". There are many philosophers.
Thales, the philosopher, lived in Asia Minor. "Philosopher" does not restrict "Thales". There is only one Thales.
Thales the philosopher lived in Asia Minor. "Philosopher" restricts "Thales". There is more than one Thales.
I bring this up to stress it's not really the words "that" or "which" that signal the meaning, but the pause or its absence.