Perhaps you were one of the 600,000 that got hit with this? Flashback Trojan
There are other, less newsworthy malware out there that could have snuck in.
If not, you could just be victim of a brute force attack on Yahoo itself. Hotmail, Yahoo, AOL, etc... e-mail is targeted heavily because of the sheer number of people using them.
When you change your password, make sure it's as complicated as possible, but still easy enough to remember. A trick many people use is to use some numbers instead of letters. For example: "tH1515h4RD3r2H4Ck" 1's are I's 3's are E's. 4's are A's. 5's are S's. Etc...