Reproducing kernels and bilinear sums for $q$-Racah and $q$-Wilson polynomials