we use this expression to say that you should not criticize others if you have similar weaknesses yourself. If you throw a stone in a house made of glass, what happens? It will break the glass. This is the metaphor behind this expression. The idea of karma also comes into play because throwing stones in a glass house could break a window and open up the door to other people doing the same thing or criticizing you for it.