Deformations with constraints: Analysis and applications in calculus of variations