1) Dot-com bust: Lots of people jumped into CS when it looked like being a programmer was a easy way to become a millionaire. When it became obvious that wasn't going to happen for most CS graduates and there was a glut of talent in the market, people switched to something else.
2) Outsourcing: Right on top of the dot-com bust was the trend towards outsourcing. There was lots of scary noise about how programmers were the next factory workers: gone overseas and never coming back.
3) H1-Bs: They hurt the supply of U.S. CS students by making wages lower which makes CS a less attractive major. (For the record, I'm pro immigration, but anti-H1-B. H1-B workers have very little ability to negotiate salary and companies like Tata abuse the H1-B system).
Issues #1 and #2 have more or less worked themselves out, so you'd expect that the current shortage will end as people start seeing CS as a good option again.