It's true that you can often see details of the aircraft on the website now, so you could have some expectations or think you have a contractual agreement to be flown on that aircraft. But in practice, airlines merely promise a best effort to bring you somewhere and can and do do a lot of things (switch airplanes, reschedule, cancel a flight outright, change the itinerary or even the means of transportation, etc.) that impact the conditions in which you will travel.
In this particular case, if you check Turkish airlines' conditions of carriage, you will read that
Carrier undertakes to use its best efforts to carry the passenger and his or her baggage with reasonable dispatch and to adhere to published schedules in effect on the date of travel.
That's really pretty vague, they don't promise much beyond getting you to your destination (or, in fact, merely trying to get you to your destination). Even regulations on monetary compensations for significant delays or the right to be informed about the name of the airline operating the flight (not the actual aircraft or aircraft type but simply the name of the airline) are relatively recent so it does not seem they have to do more than that as far as the law is concerned.
Note that in the EU, there are strict rules about compensation for delays so it certainly seems rational for the airline to bring you as soon as possible to Madrid in a slightly less comfortable aircraft rather than wait for the other one to show up and possibly be liable to pay some compensation to all passengers.