Riesz–Kolmogorov Type Compactness Criteria in Function Spaces with Applications