A couple of things here to be aware of. You are arriving in the Schengen area in Madrid and will have to clear Spanish / EU passports immigration in Madrid
This may mean a significant proportion of time waiting at immigration
I would also reconfirm with your that your baggage will be checked through, as I believed that if you are clearing immigration in Spain, you also had to clear customs. The flight connections page
Suggests that connection with luggage are made at the baggage reclaim hall. I think you then immediately re deposit your luggage at the flight connections desk
You will need to ensure that you have boarding passes issued for the Madrid Venice segment, if you do not have these as print at home documents you may have to collect these at Madrid from the airline transfer desk.
You will need these to re enter the security controlled area at Madrid, there are often queues for this at madrid.
The airport website suggested time to clear security and get to gates for the EU leg is 120 mins
Hope this helps