Both were traditionally very Catholic countries. Spain suffered a bloody civil war, in which the Right won and established a 36 year dictatorship. Poland was devastated by the Nazis and the Soviets in WW2, and endured a communist regime for 44 years thereafter.
Post-Franco Spain became a mainly center-left countryless Catholic, very welcoming to refugees, embracing LGBT causes. Post-communist Poland lurched right, re-embracing its faith, rejecting refugees, and hostile to LGBT ideology.
1