Many Spaniards keep the same close group from school or their home town for life, so the circle is warm but hard to enter. Even Spaniards who move to another city often say the same thing.
Newcomers usually have better luck through something regular and shared: a sports club, a class at a municipal cultural centre, or volunteering. Repeated contact over months is what turns friendly chat into actual invitations.
Source: https://www.expat.com/es/expat-mag/13094-por-que-es-tan-dificil-hacer-amigos-cuando-te-mudas-al-extranjero.html
Discussed: https://www.expat.com/es/forum/europa/espana/madrid/366405-como-socializar-en-madrid.html