Conditionals (Past Tense)

The subordinate clause why I was here refers to a matter which lies outside the temporal/modal framework of the conditional construction. Presumably both parties accept as a fact that I was here at some past time, so it cannot be included in the present-referent irrealis domain established by knew and would.

As for the three (or four, or five, or however many) conditionals, that is nothing but a 'baby rule' employed as a pedagogic tool to get you involved in conditional constructions; as tchrist says, it has nothing to do with the facts on the ground, and should be discarded now that your fluency has carried you beyond it.

Declerck and Reed, Conditionals: A Comprehensive Empirical Analysis (de Gruyter: 2001), classifying conditionals along syntactic, semantic and pragmatic axes, distinguish several score different types; they show that in the proper context it is possible to construct an acceptable conditional with any combination of tenses, aspects and modalities in the two clauses; and they remark specifically of what they call the ‘three canonical tense patterns’ that

There are at least three dozen ways in which conditionals of these three tense patterns (taken together) can be interpreted.

Stoutly abjure the trinity.