SNP ministers have handed more than £20million of public funds to organisations which appear to support gender self-ID.