Upvote:0
You do have to go through customs and be sure to go through the fast connection line for passport control. I have traveled all my life and Madrid was a cluster. Our gate was a connection at H2, but there were no signs pointing you in that direction. Get your gate info early if you can. Ours was not available until after we landed and Madrid doesn't have flight info readily available like U.S. airports. You will also have to go through security again.
Upvote:4
Usually you do not need to take luggage and proceed through customs. You will have just regular tag on your checked baggage, so that customs officials in Rome know if they could fine you for customs regulations. Tags with green bands are intra-EU baggage.
There could be exceptions, but you will know at departure airport, at check-in.
Note: your immigration procedures are done in Madrid, because you will enter there to Schengen Area. Just customs is done (usually) at destination. Note: Schengen Area and EU customs Area are different concepts and they have different borders.