Breakdown of Siedzieliśmy między szafą a regałem.
siedzieć
to sit
a
and / whereas (contrast)
między
between
regał
bookcase
Questions & Answers about Siedzieliśmy między szafą a regałem.
Why do we use a instead of i for "and" here?
In Polish, the phrase for "between X and Y" is always między [X] a [Y]. You must use a instead of the usual i when talking about the space separating two distinct endpoints.
Why do both szafa and regał change their endings in this sentence?
The preposition między (between) requires the nouns following it to be in the Instrumental case when describing a location. That is why the feminine noun szafa gets the -ą ending to become szafą, and the masculine noun regał gets the -em ending to become regałem.
Does the word a affect the case of regałem?
No, a is just linking the two things. The preposition między applies to both nouns in the pair. It expects both the first noun and the second noun to be in the Instrumental case.