Perfect (avoir/être + past particle) is used to describe a single, completed action in the past. For example, I ate a sandwich = J'ai mangé un sandwich. The action happened once, and it's finished.
Compare this with imperfect: I used to eat a sandwich every day = Je mangeais un sandwich tous les jours. This happened multiple times, and therefore is NOT a single action, so you cannot use the present tense. You use imperfect instead.
Another example is a single, incomplete action. For example, I was eating a sandwich when I saw my friend. = Je mangeais un sandwich quand j'ai vu mon amis. This time, the action was interrupted by another action, so it is incomplete and therefore needs imperfect, not perfect.
If unsure, if you say "used to do" or "was doing" in English, you'll usually use the imperfect tense in French.