hot in Madrid: some variations.
1) by 11 AM it is intense, dry heat so bright that you are already looking for shade. Your face is red (despite 2 litres of water intake). You take refuge in your AIRCONDITIONED hotel or apt, and eat, sleep, and hang until at least 5 or 6 when it starts to get bearable.
2) By 4-5 PM the "bochorno" weather comes in. That's like a blast of windy furnace heat that predicts a storm (or not). If you are lucky you'll hear some rumbling and maybe some actual rain.
3) The steady slow Madrid bake. 10 am, fresh, almost cool. Ah, gunna be bearable! noon, still ok. After lunch (was it the red wine)? the heat level seems close to... unbearable. After siesta, you realize the heater did go up, and now you have to wait until after sundown for the delicious night cool.
Solutions: museums, parks, pools (there are some!), a quick trip to el escorial or another coolish sierra town, and, best of all, for you young folks: party all night, sleep all day!