Violent crime against tourists is almost unreported, and compared to other major capitals, Madrid is really low on the list of crime statistics.
However, it is always much better to be safe than sorry and therefore be careful of your belongings such as bags, cameras, wallets, etc. all are needed to be kept in safe places and the tourist himself should always be alert and attentive at all times, especially if approached by a stranger, whatever the apparent reason.
Petty criminals are very clever in what they do and often work together in smaller groups, one of the group members might approach you suddenly and try to distract your attention while another person you probably won’t even notice of will try to snatch your bag or wallet or any other valuables. So better be careful at all times for your own safety and security while touring around Madrid.