The saying is ambiguous as to whether "mad" refers to angry or crazy. I've always thought the latter was intended, but there's plenty of overlap there.
"Old sayings" and their origins can be quite fascinating... srsly. We did an original play on the subject when I was in 1st grade and I've been hooked for life.