"The teacher lives in the city."
Translation:Magistra in urbe habitat.
magistrum is an accusative form and is used for the direct object of a verb. E.g. 'I have a teacher' -> magistrum/magistram habeo
Since 'the teacher' is doing the living/residing in the city, the one doing the action, we need to use a nominative form. magister and magistra are nominative forms.