Iberia would not interline with a same day AA flight on a second ticket in December for us. I would be surprised if IB Express will do it with Delta.
Madrid T4 is massive and it can easily take 10-15 minutes to walk from one end to the other. Three hours should be plenty of time but I wouldn't dawdle.