We investigate Lie algebras whose Lie bracket is also an associative or cubic associative multiplication to characterize the class of nilpotent Lie algebras with a nilindex equal to 2 or 3. In particular we study the class of 2-step nilpotent Lie algebras, their deformations and we compute the cohomology which parametrize the deformations in this class.