Most Spaniards are Catholic. On the weekend before Ash Wednesday, everyone dresses up in costumes and goes to festivals and block parties throughout their neighborhoods for one last hurrah before the start of Lent. It's like a Spanish version of Mardi Gras!
I learned about Carnival. Depending on when all holidays surrounding Easter (Good Friday and Ash Wednesday) fall on in a given year, the date of Carnival varies. This year, Carnival was on February 21 and 22.
This tradition is popular so people can celebrate and enjoy life before they sacrifice whatever it is they choose to limit for Lent. Lent is when Catholics and Christians sacrifice something that means a lot to them for 40 days (until Easter). It is to show gratitude to Jesus for sacrificing his life for his followers.
Yes, this tradition is connected to the environment because the festivals are held in different neighborhoods all throughout Spain.