I only stayed in two hostels in Madrid, but I checked out a few of them while "shopping" for hostels.
Madrid has pretty decent hostels for decent prices. For the first night, I stayed in a two star hostel. For a hostel it was pretty clean, and a twin room plus a single room cost us 60 euros. We switched to a three star hostel afterwards (triple room for 60 euros) and it was even nicer than the first.
Check out Gran Via, there are many nice hostels there.
My sister is studying abroad in Madrid and told me that Madrid has a strict system where they rate the quality of hostels, so just looking at the stars of the hostel will give you a pretty good idea of the quality.