I was in the mountains.

Literal

I [topic-は] mountain [location-に] existed [polite-past-ました].

The location particle に combined with いる (existence verb for animate beings) gives 'to be located at X.' Compare with で, which marks where an action takes place; に marks where someone is. Past tense いました locates the speaker in the mountains at some prior time.