"John" or "Matthew" are probably never going to become female. Nor will "Elizabeth" or "Katherine" become male.
"Spencer" was male when Spencer Tracy was a big name. Today it could go either way. As a family name it relates to the profession of a steward.
In Polish '...ski' is masculine and '...ska' is feminine. The prefix stays the same, so a brother and sister have slightly different surnames. (Like 'Wolski' vs 'Wolska.')
In the US some immigrants forgot this, so you get American women with a '...ski' surname.
So the whole family may just have taken the male head of house’s surname to avoid problems, or even been simply assigned his surname by immigration officials.
Many a name were changed at Ellis Island, for example.
Is it common in these cultures to use surnames as given names?