I saw some Ph.D. positions from a particular university. Most of the projects align well with my interest. So before applying, I want to write the professors some queries (e.g. just to know what he is expecting in the candidate or even I am eligible or my profile meeting his expectations or not). Is it ok if I send the same mail to all the professors I want to work with, even when they are from the same department? If they ever come to know any candidate sent the same email to all his colleagues, will it be harmful to the candidate?
It is okay in the sense that it doesn't violate any ethical rules. However, I think it is unlikely that you will find success on this path.
Professors receive an unhealthy number of emails every day, and this increases with an unhealthy number of PhD application emails in PhD application season. If you want an email to a professor to be successful, it may pay off to carefully balance two counteracting forces: on the one hand, you want to be economical with the professor's time, and on the other hand, you want to stand out in a positive way. The most straightforward way to stand out is to be specific about the professor's research: why are you particularly interested in working with this person on this project, and where in this project do you see a first solution strategy that could potentially lead to a first paper?
It is a big ask to craft an email that satisfies these constraints. However, generic emails are very likely to be ignored. So that route is probably best avoided.
It is difficult to be certain, as it is partly a matter of individual personality. I think, however, that it would be good to mention in each letter that you are also making inquiries generally in the department so that no one is surprised. And if they are slightly tailored, say mentioning a paper of theirs that you are familiar with it is a bit better.
People certainly expect that if you send them a letter you will be sending others as well.
But I wouldn't send one letter with every one copied, or worse, BCC'd.