مَرَرْتُ بِمَسَاجِدَ — I passed by mosques.
مَرَرْتُ: past tense verb with the first-person subject pronoun.
بِـ: preposition.
مَسَاجِدَ: genitive noun marked by fatḥa in place of kasra, because it is a diptote with neither al- nor iḍāfa.
The word is genitive, not accusative, even though it ends in fatḥa.