Where in scriptures or commentaries is it said that shlokas have to be interpreted as per प्रसंग (context), काल (time),स्थान (place) and परिस्थिति (situation) (and other factors, if any)?
Please give exact references.
Shankaracharya said that verses can be interpreted in different way based on context to make the statement valid in his commentary on Bhagavad geeta. I'm quoting it from this answer,
The appeal to the infallibility of the Vedic injunction is misconceived. The infallibility in question refers only to the unseen forces or apurva, and is admissible only in regards to matters not confined to the sphere of direct perceptions, etc. ..... Even a hundred statements of sruti to the effect that fire is cold and non-luminous won't prove valid. If it does make such a statement, its import will have to be interpreted differently. Otherwise, validity won't attach to it. Nothing in conflict with the means of valid cognition or with its own statements may be imputed to sruti.
Also the commentator Medhatithi gave examples (I'm providing one example) in his commentary for the Manu smriti verse
parityajedarthakāmau yau syātāṃ dharmavarjitau |
dharmaṃ cāpyasukhodarkaṃ lokasaṅkruṣṭameva ca || 4.176 ||
Meaning: He shall, avoid such wealth and pleasures as are opposed to righteousness, as also righteousness if it be conducive to unhappiness, or disapproved by the people.
Commentary: As a matter of fact, however, it can never be right to reject, on the strength of Smṛti, what has been enjoined by the Veda. The right example of the act aimed at by the Text is as follows: The custom of ‘niyoga’ (‘begetting of a child on the widowed sister-in-law’) is sanctioned by Smṛtis; but it is not performed, because it is ‘deprecated by the people;’