... when we look at this one issue in isolation.I think the problem with your argument is that other non-profits (who don't pay taxes) and private entities (who are motivated by profits) were allowed to take part in this grant. To single out religious organizations in such company does appear discriminatory.
In the wider context, churches are treated like other charities in many ways, get preferential treatment in many ways, and are disadvantaged in only a small handful of ways, with the net effect being that churches get a substantial net benefit from their unequal treatment. This ruling gives even more advantage to already advantaged organizations.
Yes, singling out religions for special treatment is discriminatory, but this ruling doesn't get rid of this double standard across the board.
My first choice would be no special treatment on the basis of religion at all, but as long as churches get special benefits, I don't have a problem with giving them special disadvantages occasionally.