It is a terrestrial orchid, I think it is an Orchis Mascula, there are many species of this genre in the Iberian peninsula.
The first terrestrial orchids of our country begin to bloom at the end of the year and end when they press the heats, in the areas at sea level they finish on July and as you go taking height they are delayed until the end of August.
One of the most beautiful we have in the peninsula is the Ciprepedium Calceolus, they are from humid areas and of a certain height, they tend to be in colonies.