On the Sample Complexity of Learning under Invariance and Geometric Stability