Hamiltonian and Lagrangian structures in integrable hierarchies and covariant field theory