Madrid is a quite safe city, so you don't have to be worry about your safety, it's not an issue!
Nevertheless as it is in any big city, you must be careful of pickpockets when visiting the busiest tourist spots, when you are in the city centre, or on the subway or bus. Be especially careful in crowded areas, as thieves are extremely skillful. There are different ways of approaching: an attractive woman distracts male victims, groups of gypsy girls ask for your support and signature for different campaigns, or asking for directions as if they were tourists too.
You also should be aware of different scams. The shell game is often seen played on the streets on a cardboard box with a group of shells. You need three shells or cards and a pea or a small ball. You would then be asked to bet and guess correctly to win back double or lose your money. The fact is that the operator is a skillful con man who hides the ball from your eyes without your noticing and your money is lost!
As a general rule it's better to be safe than sorry: try to avoid empty streets at night, only bring necessary things with you, use money belts under clothes, and get a photocopy of your important documents separate from originals.
As a conclusion: Enjoy Madrid!
The 4 Towers
Boats, Retiro park
Sorolla, impressionist painter
"The air was soft, the stars so fine, the promise of every cobbled alley so great, that I thought I was in a dream" - Jack Kerouac