Spectral Analysis of Kernel and Neural Embeddings: Optimization and Generalization