Risk Minimization from Adaptively Collected Data: Guarantees for Supervised and Policy Learning