Spain's economy is very screwed up. Unemployment rate tends to hover above 20% and I think it has the highest rate of students dropping out of basic education.
To top things off, cost of living in urban centers is way way above the median income, specially nowadays. Young families have to make do with either sharing apartments/renting rooms or living way outside city centers in small apartments. In some cases the only affordable option is renting rooms way outside the urban centers.
So the average Spanish couple has to make very hard decisions on if/when to start a family. Quite often the decision tends towards "not right now, we can't afford it."
Marketing brochures tend to emphasize Spain's "terraza" lifestyle, as in people hanging out in cafes/bars/restaurants in the afternoon, evening, and even night, and brag about the fantastic social life that sprouts from there, but the ugly truth is that one important factor of that pattern is the fact that housing is very expensive and very low-quality to the point that staying indoors in one of those flats can have a huge detrimental impact on your mental health, and the only way to avoid that is to minimize the amount of time you spend indoors.