A nonprofit attorney is not an attorney who works for free. That type of legal work is called pro bono work. Instead, a nonprofit attorney works with not-for-profit organizations, such as charities, religious organizations, private foundations, etc. Even though such organizations do not exist to earn huge profits, they still have the need for proper legal guidance.
Nonprofit attorneys work with nonprofit organizations ensuring that they are properly formed, as well as giving guidance for these organizations to maintain their not-for-profit status. These laws are in constant flux, especially as federal and state governments continue to crack down on those organizations which are not truly nonprofit.