1) Madrid is a classic "Judeo-Converso" Spanish last name. When Spanish Jews converted to Christianity in Spain in the 15th century, whether voluntarily or by force, they often took a Christian name and last name. Often, the name chosen was that of a town or city, and that is the case with the surnames of Madrid, Toledo, Sevilla, Valencia, to name a few. Madrid was the name of families in the Toledo Jewish quarter before the expulsion of 1492, and the name is found among those prosecuted by the Inquisition for relapsing into their ancient faith. I recommend the book by Pere Bonnin, Sangre Judia, which discusses the Jewish ancestry of Spanish people and lists family names of Jewish origin.
2) No, Perez is not related to the Madrid branch of my family.