It is definitely a crab - not anything spider. I originally thought it was a _Sally Lightfoot Crab_ (a common crab on Madeira from the family of _shore crabs_ ) but I agree on your comment that it is more likely a **Nimble Spray Crab** (of the _Flat Crab_ genus) as the specimen in your photo seemed a lot flatter than a shore crab (but I wasn't sure if it was just the shape of the rock). The Wikipedia article on this species says that these are also referred to as another kind of Sally Lightfoot crab, and the fact that these are in a different taxonomic family from the other ones (the shore crabs) is a topic of debate.
![enter image description here](
They are observed in the coastal Atlantic and considered native to Madeira, but have recently spread into the Mediterranean
![enter image description here](
You can view a gallery of almost 200 photos of these crabs on iNaturalist.