Is it a good idea to contact professors before applying to grad schools?
This really only works as a strategy if you have something truly meaningful to say. If you have to force yourself to do it and struggle to come up with something to say in your email, you're not helping yourself. Faculty get tons of email all the time and every year - as you say - get emails from prospective students, many of whom will not be admitted and in whom they invest no effort. So, if you genuinely think you're a good fit for a program/lab and have solid questions in mind to ask the faculty/PI of that lab that will communicate your quality and fit, this may be viable. But, I would definitely not recommend it as a general strategy.