When you read or hear a Spanish sentence about the past, you will have no trouble understanding the sentence even if you do not stop to consider the tense(s) of the verb(s) in the past. However, you will begin to understand the Spanish past tenses better if you stop to analyze which tense is used by a native speaker and why they used it. It's quite common to use both tenses in one sentence as the focus of the sentence shifts from description to action or from what was ongoing to what happened at a specific instant.
For a Spanish speaker, the use of the two past tenses happens without much thought. The speaker knows whether the intent of the sentence is focusing on background information or the action of the sentence and uses the imperfect or preterite accordingly. When learners of the language agonize over determining which tense would be correct in a given situation, most of the time they agonize in vain because the sentence will be understood regardless of whether the imperfect or preterite is used. Often the slight difference in meaning between the preterite and imperfect is unimportant.
There are, however, certain cases where the meaning of the sentence changes greatly depending on which past tense is used. Some verbs that are generally used in the imperfect will have a completely different meaning when used in the preterite, and certain idiomatic expressions are created by using both tenses in one sentence.