Manipulating magnetic anisotropy and ultrafast spin dynamics of magnetic nanostructures